EventToCommand Not working Inside DataTemplate

2 posts, 0 answers
  1. Shanmuga
    Shanmuga avatar
    15 posts
    Member since:
    Mar 2015

    Posted 23 Oct 2015 Link to this post

    Hi

    EventToCommand is not working  inside DataTemplate

    In my code <commands:EventToCommand Command="{Binding Path=CellSelectionChangedCommand}" ></commands:EventToCommand> is not fired.


    <telerik:GridViewDataColumn Header="Node Name" Width="200" ColumnGroupName="BasicInformation" x:Name="test">
    <telerik:GridViewDataColumn.CellTemplate>
    <DataTemplate>
    <telerik:RadComboBox SelectedValue="{Binding CellId}" x:Name="cbxCells1" SelectionChanged="cbxCells1_SelectionChanged"
    SelectedItem="{Binding Path=SelectedCell,Mode=TwoWay}"
    SelectedValuePath="CellId"
    ItemsSource="{Binding Path=Cells, Source={StaticResource lcgroupconfigurationModel}}"
    ItemTemplate="{StaticResource ProjectDataTemplate}"
    Command="{Binding CellSelectionChangedCommand, Source={StaticResource lcgroupconfigurationModel}}">
                                                        
    <i:Interaction.Triggers>
    <i:EventTrigger EventName="SelectionChanged">
    <commands:EventToCommand Command="{Binding Path=CellSelectionChangedCommand}" ></commands:EventToCommand>
    </i:EventTrigger>
    <i:EventTrigger EventName="DropDownOpened">
    <commands:EventToCommand Command="{Binding Path=DropDownOpenedCommand}" ></commands:EventToCommand>
    </i:EventTrigger>
    </i:Interaction.Triggers>
    </telerik:RadComboBox>
    </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>

     

    Please Help Me

     

     

  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 28 Oct 2015 Link to this post

    Hi,

    This is known framework limitation of SIlverlight. When a DataTemplate that defines any triggers is used to create content by invoking DataTemplate.LoadContent, the elements in the generated visual subtree lose the trigger logic. A possible MVVM-friendly workaround that you can use is to wrap the logic in an attached behavior that internally handles the event. Would this approach be acceptable to you?

    Regards,
    Ivan Ivanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top