Browse Source

DataGrid inertial scroll support (#13502) (#13511)

release/11.0.6
Glen Stone 3 years ago
committed by Max Katz
parent
commit
3df9ab4f63
  1. 15
      src/Avalonia.Controls.DataGrid/DataGrid.cs
  2. 8
      src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml
  3. 6
      src/Avalonia.Controls.DataGrid/Themes/Simple.xaml

15
src/Avalonia.Controls.DataGrid/DataGrid.cs

@ -412,6 +412,21 @@ namespace Avalonia.Controls
} }
} }
/// <summary>
/// Defines the <see cref="IsScrollInertiaEnabled"/> property.
/// </summary>
public static readonly AttachedProperty<bool> IsScrollInertiaEnabledProperty =
ScrollViewer.IsScrollInertiaEnabledProperty.AddOwner<DataGrid>();
/// <summary>
/// Gets or sets whether scroll gestures should include inertia in their behavior and value.
/// </summary>
public bool IsScrollInertiaEnabled
{
get => GetValue(IsScrollInertiaEnabledProperty);
set => SetValue(IsScrollInertiaEnabledProperty, value);
}
private bool _isValid = true; private bool _isValid = true;
public static readonly DirectProperty<DataGrid, bool> IsValidProperty = public static readonly DirectProperty<DataGrid, bool> IsValidProperty =

8
src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml

@ -532,9 +532,13 @@
<DataGridRowsPresenter Name="PART_RowsPresenter" <DataGridRowsPresenter Name="PART_RowsPresenter"
Grid.Row="1" Grid.Row="1"
Grid.RowSpan="2" Grid.RowSpan="2"
Grid.ColumnSpan="3" Grid.Column="0"> Grid.ColumnSpan="3"
Grid.Column="0"
ScrollViewer.IsScrollInertiaEnabled="{TemplateBinding IsScrollInertiaEnabled}">
<DataGridRowsPresenter.GestureRecognizers> <DataGridRowsPresenter.GestureRecognizers>
<ScrollGestureRecognizer CanHorizontallyScroll="True" CanVerticallyScroll="True" /> <ScrollGestureRecognizer CanHorizontallyScroll="True"
CanVerticallyScroll="True"
IsScrollInertiaEnabled="{Binding (ScrollViewer.IsScrollInertiaEnabled), ElementName=PART_RowsPresenter}" />
</DataGridRowsPresenter.GestureRecognizers> </DataGridRowsPresenter.GestureRecognizers>
</DataGridRowsPresenter> </DataGridRowsPresenter>
<Rectangle Name="PART_BottomRightCorner" <Rectangle Name="PART_BottomRightCorner"

6
src/Avalonia.Controls.DataGrid/Themes/Simple.xaml

@ -335,10 +335,12 @@
<DataGridRowsPresenter Name="PART_RowsPresenter" <DataGridRowsPresenter Name="PART_RowsPresenter"
Grid.Row="1" Grid.Row="1"
Grid.ColumnSpan="2"> Grid.ColumnSpan="2"
ScrollViewer.IsScrollInertiaEnabled="{TemplateBinding IsScrollInertiaEnabled}">
<DataGridRowsPresenter.GestureRecognizers> <DataGridRowsPresenter.GestureRecognizers>
<ScrollGestureRecognizer CanHorizontallyScroll="True" <ScrollGestureRecognizer CanHorizontallyScroll="True"
CanVerticallyScroll="True" /> CanVerticallyScroll="True"
IsScrollInertiaEnabled="{Binding (ScrollViewer.IsScrollInertiaEnabled), ElementName=PART_RowsPresenter}" />
</DataGridRowsPresenter.GestureRecognizers> </DataGridRowsPresenter.GestureRecognizers>
</DataGridRowsPresenter> </DataGridRowsPresenter>
<Rectangle Name="PART_BottomRightCorner" <Rectangle Name="PART_BottomRightCorner"

Loading…
Cancel
Save