4

刚刚检查了这个,它非常相似,但垂直滚动不是水平的。

我有一个包含分组数据的数据网格,如下所示:

我只想在水平滚动列时保持组标题信息可见。但标题滚动出窗口:

在此处输入图像描述

这是 xaml(最初来自此处),仅适用于 datagrid 组样式...如果您需要更多信息,请让我知道!

<DataGrid.GroupStyle>
    <GroupStyle>
        <GroupStyle.HeaderTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBlock Text="{Binding Path=ReferralDate}" FontWeight="Bold" Padding="3"/>
                </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 RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GroupItem}}, 
                                            Converter={StaticResource ResourceKey=groupTitleVisitsConverter}}" 
                                            Foreground="White" FontWeight="Bold"/>
                                    </StackPanel>
                                </Expander.Header>
                                <ItemsPresenter />
                            </Expander>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </GroupStyle.ContainerStyle>
    </GroupStyle>
</DataGrid.GroupStyle>
4

0 回答 0