Skip to content

Commit

Permalink
Merge pull request #417 from irihitech/grid
Browse files Browse the repository at this point in the history
feat: respect AllowAutoHide in DataGrid.
  • Loading branch information
zdpcdt authored Aug 15, 2024
2 parents b13547a + b80deac commit 421e8ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion demo/Semi.Avalonia.Demo/Pages/DataGridDemo.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
<TabControl>
<TabItem Header="DataGrid">
<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"
Margin="8"
CanUserReorderColumns="True"
CanUserResizeColumns="True"
CanUserSortColumns="True"
HeadersVisibility="All"
IsReadOnly="True"
ScrollViewer.AllowAutoHide="{Binding #ScrollViewerHide.IsChecked}"
IsEnabled="{Binding #DisableToggle.IsChecked}"
ItemsSource="{Binding GridData1}">
<DataGrid.Columns>
Expand Down
11 changes: 11 additions & 0 deletions src/Semi.Avalonia.DataGrid/DataGrid.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="SelectionMode" Value="Extended" />
<Setter Property="GridLinesVisibility" Value="None" />
<Setter Property="ScrollViewer.AllowAutoHide" Value="True" />
<Setter Property="HorizontalGridLinesBrush" Value="{DynamicResource DataGridLineBrush}" />
<Setter Property="VerticalGridLinesBrush" Value="{DynamicResource DataGridLineBrush}" />
<Setter Property="DropLocationIndicatorTemplate">
Expand Down Expand Up @@ -570,5 +571,15 @@
<Setter Property="IsVisible" Value="False" />
</Style>
</Style>

<Style Selector="^[(ScrollViewer.AllowAutoHide)=False]">
<Style Selector="^ /template/ DataGridRowsPresenter#PART_RowsPresenter">
<Setter Property="Grid.RowSpan" Value="1" />
<Setter Property="Grid.ColumnSpan" Value="2" />
</Style>
<Style Selector="^ /template/ DataGridColumnHeadersPresenter#PART_ColumnHeadersPresenter">
<Setter Property="Grid.ColumnSpan" Value="1" />
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>

0 comments on commit 421e8ec

Please sign in to comment.