Add row as group header in datagrid
I am using wpf toolkit's datagrid i want to marge a row for all its columns when a 开发者_开发技巧property IsGroup is set as true. i want to use datatrigger insteed of ivalueconverter. i have done it with ivalueconverter. One more thing is that i dont want to use the grouping functionality of datagrid. just want ted to add row at specific index no and make that row as single column. so will look like group name
<my:DataGrid.RowStyle>
<Style TargetType="{x:Type my:DataGridRow}">
<Setter Property="Background" Value="White" />
<Setter Property="Background" Value="{Binding IsGroup, Converter={StaticResource rowhighlighter}}" />
<!--<Style.Triggers>
<DataTrigger Binding="{Binding IsGroup,UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter Property="Background" Value="YellowGreen"/>
</DataTrigger>
</Style.Triggers>-->
</Style>
</my:DataGrid.RowStyle>
this style datatrigger is not working for me where i am wrong.
Your qustion is that you want to add a row as a group header. But in the description of your question you state that you don't want to use the grouping functionality of datagrid. Can you please elaborate what you want to do exactly, and why you believe you shouldn't use the grouping functionality. By grouping functionality do you mean, the ability to expand collapse rows on some column ? You can declare a GroupStyle inside your datagrid:
combine it with
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Parent"/>
</CollectionViewSource.GroupDescriptions>
Apart from what msdn provides on this subject, like introduction WPF
I found this blog usefull in getting an understanding of datagrid:
smoura's WPF blog
精彩评论