2
this 튜토리얼 다음으로 나는 Expander Header에 더 많은 데이터를 넣을 생각이 들었다. 2 개의 테이블이 있습니다 (문서 1 - * 항목). Documents로 그룹화 된 항목을 표시하고 있으므로 데이터 격자에 일부 데이터를 반복하지 않으므로 익스텐트 헤더에 배치하려고합니다.Datagrid expander (그룹화) header
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GroupItem}}, Converter={StaticResource ResourceKey=groupToTitleConverter}}" />
</StackPanel> </Expander.Header>
변환기 :
public class GroupToTitleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
GroupItem groupItem = value as GroupItem;
CollectionViewGroup collectionViewGroup = groupItem.Content as CollectionViewGroup;
EntryViewModel entryViewModel = collectionViewGroup.Items[0] as EntryViewModel;
string title = string.Format("{0} - {1} {2}", entryViewModel.Id, entryViewModel.Numar, entryViewModel.Obiect);
return title;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
이 가장 우아한 해결책이 될하지 않을 수 있습니다 헤더 타이틀을 형성하기 위해 그룹의 수집에서 첫 번째 항목을 촬영하지만, 될 것입니다
<DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Name}" />
</StackPanel>
</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">
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text=" - "/>
**<TextBlock Text="{Binding Path=Document.Number or Name2}"/>**
</StackPanel>
...
그리고 백만 달러 질문은 ...? – Silvermind
확장기 헤더에 더 많은 데이터를 표시하려면 어떻게해야합니까? – Misi
어떤 데이터가 있습니까? 좀 더 구체적이어야합니다. – Paparazzi