feat:add AutoHide ToggleSwitch to DataGrid demo.

This commit is contained in:
Zhang Dian 2024-08-15 18:53:06 +08:00
parent a3ed11fa10
commit b80deac692
2 changed files with 10 additions and 6 deletions

View File

@ -14,7 +14,10 @@
<TabControl> <TabControl>
<TabItem Header="DataGrid"> <TabItem Header="DataGrid">
<Grid RowDefinitions="Auto, *"> <Grid RowDefinitions="Auto, *">
<ToggleSwitch Grid.Row="0" Content="Disable" Name="DisableToggle"></ToggleSwitch> <StackPanel Grid.Row="0" Orientation="Horizontal">
<ToggleSwitch Content="Disable" Name="DisableToggle" />
<ToggleSwitch Content="ScrollViewerHide" Name="ScrollViewerHide" />
</StackPanel>
<DataGrid Grid.Row="1" <DataGrid Grid.Row="1"
Margin="8" Margin="8"
CanUserReorderColumns="True" CanUserReorderColumns="True"
@ -22,6 +25,7 @@
CanUserSortColumns="True" CanUserSortColumns="True"
HeadersVisibility="All" HeadersVisibility="All"
IsReadOnly="True" IsReadOnly="True"
ScrollViewer.AllowAutoHide="{Binding #ScrollViewerHide.IsChecked}"
IsEnabled="{Binding #DisableToggle.IsChecked}" IsEnabled="{Binding #DisableToggle.IsChecked}"
ItemsSource="{Binding GridData1}"> ItemsSource="{Binding GridData1}">
<DataGrid.Columns> <DataGrid.Columns>

View File

@ -471,7 +471,7 @@
<Setter Property="VerticalScrollBarVisibility" Value="Auto" /> <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="SelectionMode" Value="Extended" /> <Setter Property="SelectionMode" Value="Extended" />
<Setter Property="GridLinesVisibility" Value="None" /> <Setter Property="GridLinesVisibility" Value="None" />
<Setter Property="ScrollViewer.AllowAutoHide" Value="True"></Setter> <Setter Property="ScrollViewer.AllowAutoHide" Value="True" />
<Setter Property="HorizontalGridLinesBrush" Value="{DynamicResource DataGridLineBrush}" /> <Setter Property="HorizontalGridLinesBrush" Value="{DynamicResource DataGridLineBrush}" />
<Setter Property="VerticalGridLinesBrush" Value="{DynamicResource DataGridLineBrush}" /> <Setter Property="VerticalGridLinesBrush" Value="{DynamicResource DataGridLineBrush}" />
<Setter Property="DropLocationIndicatorTemplate"> <Setter Property="DropLocationIndicatorTemplate">
@ -571,14 +571,14 @@
<Setter Property="IsVisible" Value="False" /> <Setter Property="IsVisible" Value="False" />
</Style> </Style>
</Style> </Style>
<Style Selector="^[(ScrollViewer.AllowAutoHide)=False]"> <Style Selector="^[(ScrollViewer.AllowAutoHide)=False]">
<Style Selector="^ /template/ DataGridRowsPresenter#PART_RowsPresenter"> <Style Selector="^ /template/ DataGridRowsPresenter#PART_RowsPresenter">
<Setter Property="Grid.RowSpan" Value="1"></Setter> <Setter Property="Grid.RowSpan" Value="1" />
<Setter Property="Grid.ColumnSpan" Value="2"></Setter> <Setter Property="Grid.ColumnSpan" Value="2" />
</Style> </Style>
<Style Selector="^ /template/ DataGridColumnHeadersPresenter#PART_ColumnHeadersPresenter"> <Style Selector="^ /template/ DataGridColumnHeadersPresenter#PART_ColumnHeadersPresenter">
<Setter Property="Grid.ColumnSpan" Value="1"></Setter> <Setter Property="Grid.ColumnSpan" Value="1" />
</Style> </Style>
</Style> </Style>
</ControlTheme> </ControlTheme>