Drag and Drop different file formats

8 posts, 0 answers
  1. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 19 Apr 2011 Link to this post

    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!
  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 19 Apr 2011 Link to this post

    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
  3. DevCraft banner
  4. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 20 Apr 2011 Link to this post

    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?
  5. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 20 Apr 2011 Link to this post

    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
  6. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 20 Apr 2011 Link to this post

    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... 
  7. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 20 Apr 2011 Link to this post

    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
  8. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 23 Apr 2011 Link to this post

    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! :)
  9. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 25 Apr 2011 Link to this post

    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
Back to Top
DevCraft banner