diff --git a/Microsoft.Toolkit.Uwp.SampleApp/Models/Sample.cs b/Microsoft.Toolkit.Uwp.SampleApp/Models/Sample.cs index 43ce1887d0d..9be588da6be 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/Models/Sample.cs +++ b/Microsoft.Toolkit.Uwp.SampleApp/Models/Sample.cs @@ -675,7 +675,7 @@ private static Type LookForTypeByName(string typeName) // TODO Reintroduce graph controls // typeof(UserToPersonConverter)) // Search in Microsoft.Toolkit.Graph.Controls - ItemPlacement.Default.GetType(), // Search in Microsoft.Toolkit.Uwp.UI + ScrollItemPlacement.Default.GetType(), // Search in Microsoft.Toolkit.Uwp.UI EasingType.Default.GetType(), // Microsoft.Toolkit.Uwp.UI.Animations ImageBlendMode.Multiply.GetType(), // Search in Microsoft.Toolkit.Uwp.UI.Media Interaction.Enabled.GetType(), // Microsoft.Toolkit.Uwp.Input.GazeInteraction diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsCode.bind b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsCode.bind index 884ba387db2..22f495a7fad 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsCode.bind +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsCode.bind @@ -3,7 +3,7 @@ using Microsoft.Toolkit.Uwp.UI; // Scrolling with index -await MyGridView.SmoothScrollIntoViewWithIndexAsync(index: int, itemPlacement: ItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int); +await MyGridView.SmoothScrollIntoViewWithIndexAsync(index: int, itemPlacement: ScrollItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int); // Scrolling with item -await MyGridView.SmoothScrollIntoViewWithItemAsync(item: object, itemPlacement: ItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int); +await MyGridView.SmoothScrollIntoViewWithItemAsync(item: object, itemPlacement: ScrollItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int); diff --git a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsPage.xaml.cs b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsPage.xaml.cs index 8a0a3a021f6..b79849ef196 100644 --- a/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsPage.xaml.cs +++ b/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsPage.xaml.cs @@ -42,13 +42,13 @@ private void Load() var index = int.TryParse(IndexInput.Text, out var i) ? i : 0; var itemPlacement = ItemPlacementInput.SelectedItem switch { - "Default" => ItemPlacement.Default, - "Left" => ItemPlacement.Left, - "Top" => ItemPlacement.Top, - "Center" => ItemPlacement.Center, - "Right" => ItemPlacement.Right, - "Bottom" => ItemPlacement.Bottom, - _ => ItemPlacement.Default + "Default" => ScrollItemPlacement.Default, + "Left" => ScrollItemPlacement.Left, + "Top" => ScrollItemPlacement.Top, + "Center" => ScrollItemPlacement.Center, + "Right" => ScrollItemPlacement.Right, + "Bottom" => ScrollItemPlacement.Bottom, + _ => ScrollItemPlacement.Default }; var disableAnimation = DisableAnimationInput.IsChecked ?? false; diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ListViewExtensions.SmoothScrollIntoView.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ListViewExtensions.SmoothScrollIntoView.cs index da5b7346c28..419471d959b 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ListViewExtensions.SmoothScrollIntoView.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ListViewExtensions.SmoothScrollIntoView.cs @@ -27,7 +27,7 @@ public static partial class ListViewExtensions /// Adds additional horizontal offset /// Adds additional vertical offset /// Note: Even though this return , it will not wait until the scrolling completes - public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase listViewBase, int index, ItemPlacement itemPlacement = ItemPlacement.Default, bool disableAnimation = false, bool scrollIfVisible = true, int additionalHorizontalOffset = 0, int additionalVerticalOffset = 0) + public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase listViewBase, int index, ScrollItemPlacement itemPlacement = ScrollItemPlacement.Default, bool disableAnimation = false, bool scrollIfVisible = true, int additionalHorizontalOffset = 0, int additionalVerticalOffset = 0) { if (index > (listViewBase.Items.Count - 1)) { @@ -122,7 +122,7 @@ public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase li { switch (itemPlacement) { - case ItemPlacement.Default: + case ScrollItemPlacement.Default: if (previousXOffset <= maxXPosition && previousXOffset >= minXPosition) { finalXPosition = previousXOffset + additionalHorizontalOffset; @@ -151,29 +151,29 @@ public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase li break; - case ItemPlacement.Left: + case ScrollItemPlacement.Left: finalXPosition = maxXPosition + additionalHorizontalOffset; finalYPosition = previousYOffset + additionalVerticalOffset; break; - case ItemPlacement.Top: + case ScrollItemPlacement.Top: finalXPosition = previousXOffset + additionalHorizontalOffset; finalYPosition = maxYPosition + additionalVerticalOffset; break; - case ItemPlacement.Center: + case ScrollItemPlacement.Center: var centreX = (listViewBaseWidth - selectorItemWidth) / 2.0; var centreY = (listViewBaseHeight - selectorItemHeight) / 2.0; finalXPosition = maxXPosition - centreX + additionalHorizontalOffset; finalYPosition = maxYPosition - centreY + additionalVerticalOffset; break; - case ItemPlacement.Right: + case ScrollItemPlacement.Right: finalXPosition = minXPosition + additionalHorizontalOffset; finalYPosition = previousYOffset + additionalVerticalOffset; break; - case ItemPlacement.Bottom: + case ScrollItemPlacement.Bottom: finalXPosition = previousXOffset + additionalHorizontalOffset; finalYPosition = minYPosition + additionalVerticalOffset; break; @@ -199,7 +199,7 @@ public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase li /// Adds additional horizontal offset /// Adds additional vertical offset /// Note: Even though this return , it will not wait until the scrolling completes - public static async Task SmoothScrollIntoViewWithItemAsync(this ListViewBase listViewBase, object item, ItemPlacement itemPlacement = ItemPlacement.Default, bool disableAnimation = false, bool scrollIfVisibile = true, int additionalHorizontalOffset = 0, int additionalVerticalOffset = 0) + public static async Task SmoothScrollIntoViewWithItemAsync(this ListViewBase listViewBase, object item, ScrollItemPlacement itemPlacement = ScrollItemPlacement.Default, bool disableAnimation = false, bool scrollIfVisibile = true, int additionalHorizontalOffset = 0, int additionalVerticalOffset = 0) { await SmoothScrollIntoViewWithIndexAsync(listViewBase, listViewBase.Items.IndexOf(item), itemPlacement, disableAnimation, scrollIfVisibile, additionalHorizontalOffset, additionalVerticalOffset); } diff --git a/Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ItemPlacement.cs b/Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ScrollItemPlacement.cs similarity index 96% rename from Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ItemPlacement.cs rename to Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ScrollItemPlacement.cs index 0a35a311bdb..4b5e2a583fd 100644 --- a/Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ItemPlacement.cs +++ b/Microsoft.Toolkit.Uwp.UI/Extensions/ListViewBase/ScrollItemPlacement.cs @@ -7,7 +7,7 @@ namespace Microsoft.Toolkit.Uwp.UI /// /// Item Position /// - public enum ItemPlacement + public enum ScrollItemPlacement { /// /// If visible then it will not scroll, if not then item will be aligned to the nearest edge