DataGridTemplateColumn Event Behavior

2 posts, 0 answers
  1. Perry
    Perry avatar
    6 posts
    Member since:
    Jun 2009

    Posted 03 Dec 2014 Link to this post

    I want to have the Checked Event Binded to my RelayCommand in the ViewModel. I try to do this via an behavior but every possible implementation I try isn't working.
    Do I miss something?

                                                <CheckBox IsChecked="{Binding InCollection}">
                                                        <core:EventTriggerBehavior EventName="Checked">
                                                                Command="{Binding InCollectionCommand, Mode=OneWay}"
                                                                InputConverter="{StaticResource CheckBoxEventArgsConverter}"/>

    Thank you in advance.
    Perry van der Meeren
  2. Rosy Topchiyska
    Rosy Topchiyska avatar
    547 posts

    Posted 08 Dec 2014 Link to this post

    Hi Perry,

    Thank you for contacting us.

    The problem is that the context of the cell template is the item from the ItemsSource collection, not the ViewModel. You can either define the command in the data item, or you can define the ViewModel as a static resource in order to be able to bind to its properties in the cell template. I have attached a sample project that demonstrates the second scenario.

    I hope this helps. Please, let us know if you have further questions.

    Rosy Topchiyska

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top