RadGridView Triggers and EditTemplateSelector

4 posts, 0 answers
  1. Rotem
    Rotem avatar
    25 posts
    Member since:
    Sep 2010

    Posted 08 Dec 2010 Link to this post

    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?

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 13 Dec 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Rotem
    Rotem avatar
    25 posts
    Member since:
    Sep 2010

    Posted 14 Dec 2010 Link to this post

    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.

     

  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 14 Dec 2010 Link to this post

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