1
我正在显示作业。乔布斯有这样的规定:DataGrid中的绑定问题GoupStyle
public enum JobState
{
Done,
Running,
Overdue,
Disabled
}
当State
显示在我对他们DataGrid
I组的工作,这是按预期工作。
我跟着这个example.问题是我想为State
的Name
添加一个标头给每个分组部分。
我只是不确定GroupItem
的DataContext
究竟是什么。
也许RelativeSource
有帮助吗? - 我无法完成任何建议?
<DataGrid ItemsSource="{Binding Path=JobCollectionView}" [..]>
<DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=State}" />
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True">
<Expander.Header>
<StackPanel Orientation="Horizontal">
//Error is here: <TextBlock Text="{Binding Path=StateDescription}" />
<TextBlock Text="{Binding Path=ItemCount}"/>
<TextBlock Text=" Jobs"/>
</StackPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</DataGrid.GroupStyle>
thx。我在教程中弄错了原因,在RowLevel上也有一个名称属性。 –