【发布时间】:2015-08-14 13:31:14
【问题描述】:
我有一个带有 Expander 的 Datagrid,如下所示:
<DataGrid ItemsSource="{Binding}" Name="MainDataGrid"
AutoGenerateColumns="False"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
SelectionMode="Extended"
CanUserDeleteRows="False"
CanUserAddRows="False"
SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
>
<DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander Background="#F0F7FC" BorderThickness="0" BorderBrush="BlanchedAlmond" >
<Expander.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="Text" />
</StackPanel>
</Expander.Header>
<ItemsPresenter />
</Expander >
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</DataGrid.GroupStyle>
</DataGrid>
数据网格有一个冻结列和一些可变列。当我垂直滚动时,扩展器标题也会滚动并消失。有没有办法冻结膨胀头?
滚动前的DataGrid:
DataGrid 滚动后(Expander 标头滚开):
【问题讨论】:
标签: c# wpf datagrid scrollviewer expander