WPF DataGridRow Template - how to achieve Selected event
Posted
by
user1809972
on Stack Overflow
See other posts from Stack Overflow
or by user1809972
Published on 2012-11-08T16:58:45Z
Indexed on
2012/11/08
17:00 UTC
Read the original article
Hit count: 247
I would like to override the DataGridRow template depending on the datatype of object bound to the grid. If the type is label, it just shows a Label. Otehrwise, it shows the cells. Follwing is the xaml.
<DataTrigger Binding="{Binding Path=IsLabel, UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Grid>
<Label HorizontalAlignment="Center" Padding="3,3,3,3" FontWeight="Bold" Content="{Binding Id}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
The grid looks ok. But, when the Label is clicked, it doesnt raise the Selection changed event for the DataGridRow. How do I achieve this behaviour? This label should just behave as any other DataGridRow(with the default template).
Thanks
© Stack Overflow or respective owner