feat: implementation for DataGrid.

This commit is contained in:
Dong Bin
2025-03-13 11:24:17 +08:00
parent 9aa24c066b
commit cf90be7cea
2 changed files with 9 additions and 5 deletions

View File

@@ -15,8 +15,9 @@
<TabItem Header="DataGrid"> <TabItem Header="DataGrid">
<Grid RowDefinitions="Auto, *"> <Grid RowDefinitions="Auto, *">
<StackPanel Grid.Row="0" Orientation="Horizontal"> <StackPanel Grid.Row="0" Orientation="Horizontal">
<ToggleSwitch Content="Disable" Name="DisableToggle" /> <ToggleSwitch Content="Enable" Name="enable" IsChecked="True" />
<ToggleSwitch Content="ScrollViewerHide" Name="ScrollViewerHide" /> <ToggleSwitch Content="Inset Content" Name="inset" />
<ToggleSwitch Content="ScrollBar Auto Hide" Name="autohide"></ToggleSwitch>
</StackPanel> </StackPanel>
<DataGrid Grid.Row="1" <DataGrid Grid.Row="1"
Margin="8" Margin="8"
@@ -25,8 +26,9 @@
CanUserSortColumns="True" CanUserSortColumns="True"
HeadersVisibility="All" HeadersVisibility="All"
IsReadOnly="True" IsReadOnly="True"
ScrollViewer.AllowAutoHide="{Binding #ScrollViewerHide.IsChecked}" Classes.InsetContent="{Binding #inset.IsChecked}"
IsEnabled="{Binding #DisableToggle.IsChecked}" ScrollViewer.AllowAutoHide="{Binding #autohide.IsChecked}"
IsEnabled="{Binding #enable.IsChecked}"
ItemsSource="{Binding GridData1}"> ItemsSource="{Binding GridData1}">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn <DataGridTextColumn

View File

@@ -530,6 +530,7 @@
Name="PART_VerticalScrollbar" Name="PART_VerticalScrollbar"
Grid.Row="1" Grid.Row="1"
Grid.Column="2" Grid.Column="2"
AllowAutoHide="{Binding Path=(ScrollViewer.AllowAutoHide), RelativeSource={RelativeSource TemplatedParent}}"
Orientation="Vertical" /> Orientation="Vertical" />
<Grid <Grid
@@ -540,6 +541,7 @@
<ScrollBar <ScrollBar
Name="PART_HorizontalScrollbar" Name="PART_HorizontalScrollbar"
Grid.Column="1" Grid.Column="1"
AllowAutoHide="{Binding Path=(ScrollViewer.AllowAutoHide), RelativeSource={RelativeSource TemplatedParent}}"
Height="{DynamicResource ScrollBarSize}" Height="{DynamicResource ScrollBarSize}"
Orientation="Horizontal" /> Orientation="Horizontal" />
</Grid> </Grid>
@@ -572,7 +574,7 @@
</Style> </Style>
</Style> </Style>
<Style Selector="^[(ScrollViewer.AllowAutoHide)=False]"> <Style Selector="^.InsetContent">
<Style Selector="^ /template/ DataGridRowsPresenter#PART_RowsPresenter"> <Style Selector="^ /template/ DataGridRowsPresenter#PART_RowsPresenter">
<Setter Property="Grid.RowSpan" Value="1" /> <Setter Property="Grid.RowSpan" Value="1" />
<Setter Property="Grid.ColumnSpan" Value="2" /> <Setter Property="Grid.ColumnSpan" Value="2" />