This is a migrated thread and some comments may be shown as answers.

Drag and Drop different file formats

7 Answers 91 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 19 Apr 2011, 02:11 PM
Hi Telerik Team!

My problem is a drag and drop feature which drags different file formats such as .txt .doc. pdf format into one container... An example of code is this...  

In MainPage.xaml

<UserControl x:Class="DesktopDragandDrop.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="336" d:DesignWidth="440">


    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="200" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" AllowDrop="True" Drop="LayoutRoot_Drop" Background="#f0f0f0">
            <TextBlock Text="Drop some files here!" FontSize="24" TextAlignment="Center" VerticalAlignment="Center" />
        </Grid>
        <TextBlock x:Name="output" Grid.Row="1" />
    </Grid>
</UserControl>



While, in MainPage.xaml.cs ...

namespace DesktopDragandDrop
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }


        private void LayoutRoot_Drop(object sender, DragEventArgs e)
        {
            FileInfo[] files = ( FileInfo[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
            StringBuilder content = new StringBuilder();

            foreach (FileInfo file in files)
            {
                content.Append(file.Name);
                content.Append(Environment.NewLine);
            }

            output.Text = content.ToString();
        }
    }
}

In this code, we can drop only the filename of the file into a textblock... How can I drop the real content of .txt file or .doc file or .pdf file into a container?  

I hope you can answer this question.. 

Thank you!

7 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 19 Apr 2011, 05:06 PM
Hi Vincent,

 The functionality you refer to is actually Silverlight's built-in drag'n'drop ability, it has nothing to do with RadDragAndDropManager.

 However, here is a tutorial explaining how to drag and drop files onto Silverlight and read them: Silverlight 4: How to Drag and Drop External Files?

Greetings,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vincent
Top achievements
Rank 1
answered on 20 Apr 2011, 08:16 AM
HI... Thanks for responding..

Thanks for giving information about RadDragandDropManager... I have seen some examples of RadDragandDropManager, but these examples are dragging and dropping differerent image files. Is this RadDragandDropManager can support other different file formats such as .doc, pdf or xls? if so, is there an example of this?
0
Yavor Georgiev
Telerik team
answered on 20 Apr 2011, 09:31 AM
Hi Vincent,

 Drag and drop can only give you the contents of the file as a stream. It is up to you to manipulate them as you wish. However, you can use our RadRichTextBox to display .doc, .html, .rtf, etc. files once you have acquired their contents.

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vincent
Top achievements
Rank 1
answered on 20 Apr 2011, 12:23 PM
Ahhmm... Yeah... I know thatRadRichTextBox can display .doc .html and etc. files... What do you mean by "Drag and drop can only give you the contents of the file as a stream"? So, there is no way to drag and drop .doc file, etc. file in silverlight application?????

Thanks again for responding... 
0
Yavor Georgiev
Telerik team
answered on 20 Apr 2011, 04:24 PM
Hello Vincent,

 I think you misunderstood me - drag and drop can give you the contents of any file - .doc, .txt, .wav, as a stream. It is up to you to do something with the contents of the stream. Please experiment with the example I linked to in my first post.

Best wishes,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Vincent
Top achievements
Rank 1
answered on 23 Apr 2011, 12:37 PM
HI! Thanks!!! I am able to drag and drop the .doc file, .txt file and image files in a textbox.. My another problem is, how about if there are charts and images in .doc file, is it still possible to drag and drop the .doc file(with charts and images) in a textbox?

Thanks for the help! :)
0
Pavel Pavlov
Telerik team
answered on 25 Apr 2011, 09:47 AM
Hello Vincent,

I am afraid it will not be possible without writing your own logic to parse the incoming stream and convert it to a format suitable to be displayed in the RichTextBox.

Our Drag and Drop provider has just the capability to manage events around  what you drag , where you drop it e.t.c. and not the content itself.

I would recommend for questions specific to "how to display your data in RadRichTextBox" to open a separate thread in the RadRichTextBox  dedicated section.

Regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
DragAndDrop
Asked by
Vincent
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Vincent
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or