From 3df9ab4f6354d2bef72e4e97b5e66321f9516043 Mon Sep 17 00:00:00 2001 From: Glen Stone Date: Mon, 6 Nov 2023 18:45:33 -0500 Subject: [PATCH] DataGrid inertial scroll support (#13502) (#13511) --- src/Avalonia.Controls.DataGrid/DataGrid.cs | 15 +++++++++++++++ src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml | 8 ++++++-- src/Avalonia.Controls.DataGrid/Themes/Simple.xaml | 6 ++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Controls.DataGrid/DataGrid.cs b/src/Avalonia.Controls.DataGrid/DataGrid.cs index 311fb3de40..d7d50f1d6e 100644 --- a/src/Avalonia.Controls.DataGrid/DataGrid.cs +++ b/src/Avalonia.Controls.DataGrid/DataGrid.cs @@ -412,6 +412,21 @@ namespace Avalonia.Controls } } + /// + /// Defines the property. + /// + public static readonly AttachedProperty IsScrollInertiaEnabledProperty = + ScrollViewer.IsScrollInertiaEnabledProperty.AddOwner(); + + /// + /// Gets or sets whether scroll gestures should include inertia in their behavior and value. + /// + public bool IsScrollInertiaEnabled + { + get => GetValue(IsScrollInertiaEnabledProperty); + set => SetValue(IsScrollInertiaEnabledProperty, value); + } + private bool _isValid = true; public static readonly DirectProperty IsValidProperty = diff --git a/src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml b/src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml index 2d40721bbf..4f4ae74dd9 100644 --- a/src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml +++ b/src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml @@ -532,9 +532,13 @@ + Grid.ColumnSpan="3" + Grid.Column="0" + ScrollViewer.IsScrollInertiaEnabled="{TemplateBinding IsScrollInertiaEnabled}"> - + + Grid.ColumnSpan="2" + ScrollViewer.IsScrollInertiaEnabled="{TemplateBinding IsScrollInertiaEnabled}"> + CanVerticallyScroll="True" + IsScrollInertiaEnabled="{Binding (ScrollViewer.IsScrollInertiaEnabled), ElementName=PART_RowsPresenter}" />