Customize Upload

4 posts, 1 answers
  1. Chen
    Chen avatar
    18 posts
    Member since:
    Apr 2012

    Posted 31 Jul 2012 Link to this post

    Hi,

    I have two questions about the upload.

     

    1.  Is there any way to custom upload so that I can open a file by clicking on the file item in the upload (see the attachment)?
    2. After upload files, can we remove one or more files in the list (see the attachment too)?

    Thanks.

  2. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 01 Aug 2012 Link to this post

    Hi Chen, 

    Let me get straight to your questions:

    1. open a file by clicking on the file item in the upload  - The RadUploadItems don't expose a Click event so you can either handle the RadUpload.SelectionChanged event to open the files or attach a handler for the MouseLeftButtonUp event on the RadUploadItems:
    this.AddHandler(RadUploadItem.MouseLeftButtonUpEvent, new MouseButtonEventHandler(OnItemClicked),true);

    void OnItemClicked(object sender, MouseButtonEventArgs e)
    {
        RadUploadItem item = (e.OriginalSource as FrameworkElement).ParentOfType<RadUploadItem>();
        if (item != null)
        {
            foreach (RadUploadSelectedFile file in xRadUpload.CurrentSession.SelectedFiles)
            {
                if (file.Name == item.FileName)
                {
                    //implement your logic that opens the files
                }
            }
        }
    }

    2. After upload files, can we remove one or more files in the list - You can edit the default Metro style of the RadUploadItems to make sure that the Close button element is always visible. By default its Visibility property is controlled through one private property so you can just edit its definition to remove the Visibility property at all.  

    I attached a sample solution to get you started.

    Greetings,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Chen
    Chen avatar
    18 posts
    Member since:
    Apr 2012

    Posted 02 Aug 2012 Link to this post

    Hi Tina,

    Thanks a lot for your reply. I'll try your sample code.

    This leads to another question. How can I open file per file type?

    Let's say a user browsed and selected a .txt file, a .doc file and a.jpg file. When the user click on the .txt file, .doc file, or the .jpg file, I would like to open it in notepad.exe, MS Word.exe or Paint.exe respectively. How can I do it in silverlight?

    Thanks again.
    Chen
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 07 Aug 2012 Link to this post

    Hello Chen,

    As opening a file in an external program is a scenario that falls outside the RadControls scope, you can try to find suitable approaches around the net.

    The following links can give you ideas on how to get started:

    Regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top