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

RadGridView Triggers and EditTemplateSelector

3 Answers 312 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rotem
Top achievements
Rank 1
Rotem asked on 08 Dec 2010, 03:22 PM

I'm using WPF RadGridView Q3-2010.

My purpose is to set the column template based on its data context while in edit mode. When not in edit mode the column will have triggers to customize the template.

I’m using CellEditTemplateSelector for switching templates according to the data context, but when I tried to enter triggers to the DataTemplate of the GridViewDataColumn.CellTemplate - I found that these triggers don’t work.

I read in this forum that in order to work with triggers on RadGridView, I need to set the ContentTemplate of the GridViewCell within the GridViewDataColumn.CellStyle attribute. After doing so, the triggers started to work, but the CellEditTemplateSelector Stopped working correctly. The Selector chooses the right template but the grid doesn’t use it, Moreover, the Data Context has been changed causing the grid to stop showing data after it enters the Edit Mode.

What do I need to do in order to make the triggers work with the edit template selector?

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 13 Dec 2010, 03:18 PM
Hello Rotem,

The behavior you experience is the expected one as once you define a ContentTemplate, it removes the editing functionality. What you can do is to use a CellStyleSelector for designing the cell style and CellEditTemplateSelector for defining its state in edit mode.
 

Regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Rotem
Top achievements
Rank 1
answered on 14 Dec 2010, 10:39 AM

Hi Maya,

I replaced my CellStyle with a CellStyleSelector as you suggested, and now I have two Selectors:
CellEditTemplateSelector="{StaticResource propertyEditTemplateSelector}"
CellStyleSelector="{StaticResource propertyStyleSelector}"

The selectors are working as expected. The edit template selector is called only when the cell is in edit mode and it chooses the right template and the style selector is called when the cell is not in edit mode.

But this change didn’t solve the problem.
1 – After the first time the cell enters edit mode, it seems that the cell loses its data context – therefor  all the binding stops working and only the const labels are shown.
2 – In edit mode, although the edit template selector chooses the right template, the cell doesn’t use it.

 

0
Maya
Telerik team
answered on 14 Dec 2010, 11:52 AM
Hello Rotem,

I am sending you a sample project illustrating the implementation of CellEditTemplateSelector and CellStyleSelector. Please take a look at it and let me know if there is some misunderstandings according to your requirements. If needed, you may change the sample project and send it back to me so that I could see your exact settings.  

Greetings,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
GridView
Asked by
Rotem
Top achievements
Rank 1
Answers by
Maya
Telerik team
Rotem
Top achievements
Rank 1
Share this question
or