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

Add image to cell in dragged row

3 Answers 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Carlos
Top achievements
Rank 1
Carlos asked on 26 Apr 2013, 10:57 AM
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.

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 29 Apr 2013, 12:43 PM
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.

0
Carlos
Top achievements
Rank 1
answered on 29 Apr 2013, 01:16 PM
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.
0
Nick
Telerik team
answered on 01 May 2013, 01:54 PM
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.

Tags
GridView
Asked by
Carlos
Top achievements
Rank 1
Answers by
Nick
Telerik team
Carlos
Top achievements
Rank 1
Share this question
or