Add image to cell in dragged row

4 posts, 0 answers
  1. Carlos
    Carlos avatar
    3 posts
    Member since:
    May 2011

    Posted 26 Apr 2013 Link to this post

    Hello,

    In my wpf application i've a feature of drag and drop of grid view rows and i need to add an image to one cell in the row dragged.

    To do this, i create the image object dynamically with this code:
               
    var cellImage = new Image() { Width = 20, Height = 20 };
    var imageUri = "../AppResources/Images/flag.png";
    cellImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(imageUri, UriKind.Relative));


    And i add the image to the cell i want:
    this.jobsGridView.CurrentCell.ParentRow.Cells[2].Content = cellImage;

    The image is added to the cell of the dragged row but also added to some other rows in the gridview.

    Do you know the cause of this behavior?

    Thanks.
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 29 Apr 2013 Link to this post

    Hi Carlos,

    Basically it is not recommended to use the VisualElements of the GridView and set their contents directly, because you can have problems with the Virtualization. We strongly recommend using a binding to achieve the desired effect.

    Nevertheless, may I ask you what exactly are you aiming to achieve so we can find a more elegant solution? 

    Looking forward to hearing from you! 

    Greetings,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Carlos
    Carlos avatar
    3 posts
    Member since:
    May 2011

    Posted 29 Apr 2013 Link to this post

    Hi Nikolay,

    Thanks for you reply.

    Basically, i have a gridview and a scheduleview and i can drag rows from gridview and drop them in the scheduleview and automatically create appointments. For each appointment created, i have to show a flag image in the corresponding row of the gridview to signal that the row has been processed.
    The aim is to show this flag only for the rows processed in the current user session, thus this is not a persistent information.


    Regards,
    Carlos.
  4. Nick
    Admin
    Nick avatar
    593 posts

    Posted 01 May 2013 Link to this post

    Hi Carlos,

    In that case I would recommend using our ImageColumn with a StyleSelector which relies on a property in your business object which says whether your object is dragged or not.

    Hope this helps! 

    All the best,
    Nikolay Vasilev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top