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

EventToCommand Not working Inside DataTemplate

1 Answer 36 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shanmuga
Top achievements
Rank 1
Shanmuga asked on 23 Oct 2015, 02:49 PM

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

 

 

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 28 Oct 2015, 02:42 PM
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
Tags
General Discussions
Asked by
Shanmuga
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or