diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index 166b98436e..83776ec2c1 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -144,9 +144,12 @@ - + + + + diff --git a/samples/ControlCatalog/Pages/ScrollSnapPage.xaml b/samples/ControlCatalog/Pages/ScrollSnapPage.xaml new file mode 100644 index 0000000000..e7e1060f31 --- /dev/null +++ b/samples/ControlCatalog/Pages/ScrollSnapPage.xaml @@ -0,0 +1,222 @@ + + + Scrollviewer can snap supported content both vertically and horizontally. Snapping occurs from scrolling with touch or pen, or using the pointer wheel. + + + + + + + + + + + + + + + + Vertical Snapping + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Horizontal Snapping + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog/Pages/ScrollSnapPage.xaml.cs b/samples/ControlCatalog/Pages/ScrollSnapPage.xaml.cs new file mode 100644 index 0000000000..97aeb6bcdb --- /dev/null +++ b/samples/ControlCatalog/Pages/ScrollSnapPage.xaml.cs @@ -0,0 +1,67 @@ +using System.Collections.Generic; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Markup.Xaml; +using MiniMvvm; + +namespace ControlCatalog.Pages +{ + public class ScrollSnapPageViewModel : ViewModelBase + { + private SnapPointsType _snapPointsType; + private SnapPointsAlignment _snapPointsAlignment; + private bool _areSnapPointsRegular; + + public ScrollSnapPageViewModel() + { + + AvailableSnapPointsType = new List() + { + SnapPointsType.None, + SnapPointsType.Mandatory, + SnapPointsType.MandatorySingle + }; + + AvailableSnapPointsAlignment = new List() + { + SnapPointsAlignment.Near, + SnapPointsAlignment.Center, + SnapPointsAlignment.Far, + }; + } + + public bool AreSnapPointsRegular + { + get => _areSnapPointsRegular; + set => this.RaiseAndSetIfChanged(ref _areSnapPointsRegular, value); + } + + public SnapPointsType SnapPointsType + { + get => _snapPointsType; + set => this.RaiseAndSetIfChanged(ref _snapPointsType, value); + } + + public SnapPointsAlignment SnapPointsAlignment + { + get => _snapPointsAlignment; + set => this.RaiseAndSetIfChanged(ref _snapPointsAlignment, value); + } + public List AvailableSnapPointsType { get; } + public List AvailableSnapPointsAlignment { get; } + } + public class ScrollSnapPage : UserControl + { + public ScrollSnapPage() + { + this.InitializeComponent(); + + DataContext = new ScrollSnapPageViewModel(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml index 0eceb9e07d..1741c796db 100644 --- a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml +++ b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml @@ -31,141 +31,5 @@ Source="/Assets/delicate-arch-896885_640.jpg" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs index 10244af5f3..dcd7a88a56 100644 --- a/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs +++ b/samples/ControlCatalog/Pages/ScrollViewerPage.xaml.cs @@ -11,9 +11,6 @@ namespace ControlCatalog.Pages private bool _allowAutoHide; private ScrollBarVisibility _horizontalScrollVisibility; private ScrollBarVisibility _verticalScrollVisibility; - private SnapPointsType _verticalSnapPointsType; - private SnapPointsAlignment _verticalSnapPointsAlignment; - private bool _areSnapPointsRegular; public ScrollViewerPageViewModel() { @@ -25,20 +22,6 @@ namespace ControlCatalog.Pages ScrollBarVisibility.Disabled, }; - AvailableSnapPointsType = new List() - { - SnapPointsType.None, - SnapPointsType.Mandatory, - SnapPointsType.MandatorySingle - }; - - AvailableSnapPointsAlignment = new List() - { - SnapPointsAlignment.Near, - SnapPointsAlignment.Center, - SnapPointsAlignment.Far, - }; - HorizontalScrollVisibility = ScrollBarVisibility.Auto; VerticalScrollVisibility = ScrollBarVisibility.Auto; AllowAutoHide = true; @@ -50,12 +33,6 @@ namespace ControlCatalog.Pages set => this.RaiseAndSetIfChanged(ref _allowAutoHide, value); } - public bool AreSnapPointsRegular - { - get => _areSnapPointsRegular; - set => this.RaiseAndSetIfChanged(ref _areSnapPointsRegular, value); - } - public ScrollBarVisibility HorizontalScrollVisibility { get => _horizontalScrollVisibility; @@ -68,21 +45,7 @@ namespace ControlCatalog.Pages set => this.RaiseAndSetIfChanged(ref _verticalScrollVisibility, value); } - public SnapPointsType VerticalSnapPointsType - { - get => _verticalSnapPointsType; - set => this.RaiseAndSetIfChanged(ref _verticalSnapPointsType, value); - } - - public SnapPointsAlignment VerticalSnapPointsAlignment - { - get => _verticalSnapPointsAlignment; - set => this.RaiseAndSetIfChanged(ref _verticalSnapPointsAlignment, value); - } - public List AvailableVisibility { get; } - public List AvailableSnapPointsType { get; } - public List AvailableSnapPointsAlignment { get; } } public class ScrollViewerPage : UserControl