diff --git a/docs/user-interface/controls/collectionview/includes/scrolling-tip.md b/docs/user-interface/controls/collectionview/includes/scrolling-tip.md index 84192e68d..9d4d299cc 100644 --- a/docs/user-interface/controls/collectionview/includes/scrolling-tip.md +++ b/docs/user-interface/controls/collectionview/includes/scrolling-tip.md @@ -1,7 +1,7 @@ --- ms.topic: include -ms.date: 06/09/2023 +ms.date: 01/17/2025 --- > [!TIP] -> Placing a inside a can stop the scrolling, and can limit the number of items that are displayed. In this situation, replace the with a . +> Placing a inside a or can prevent the from scrolling, can prevent the method from scrolling the , and can limit the number of items that are displayed. In this situation, replace the or with a . diff --git a/docs/user-interface/controls/collectionview/scrolling.md b/docs/user-interface/controls/collectionview/scrolling.md index 6d62bf056..495f9d731 100644 --- a/docs/user-interface/controls/collectionview/scrolling.md +++ b/docs/user-interface/controls/collectionview/scrolling.md @@ -8,13 +8,13 @@ ms.date: 09/30/2024 [![Browse sample.](~/media/code-sample.png) Browse the sample](/samples/dotnet/maui-samples/userinterface-collectionview) -The .NET Multi-platform App UI (.NET MAUI) defines two `ScrollTo` methods, that scroll items into view. One of the overloads scrolls the item at the specified index into view, while the other scrolls the specified item into view. Both overloads have additional arguments that can be specified to indicate the group the item belongs to, the exact position of the item after the scroll has completed, and whether to animate the scroll. +The .NET Multi-platform App UI (.NET MAUI) defines two methods, that scroll items into view. One of the overloads scrolls the item at the specified index into view, while the other scrolls the specified item into view. Both overloads have additional arguments that can be specified to indicate the group the item belongs to, the exact position of the item after the scroll has completed, and whether to animate the scroll. - defines a `ScrollToRequested` event that is fired when one of the `ScrollTo` methods is invoked. The `ScrollToRequestedEventArgs` object that accompanies the `ScrollToRequested` event has many properties, including `IsAnimated`, `Index`, `Item`, and `ScrollToPosition`. These properties are set from the arguments specified in the `ScrollTo` method calls. + defines a event that is fired when one of the methods is invoked. The object that accompanies the event has many properties, including `IsAnimated`, `Index`, `Item`, and `ScrollToPosition`. These properties are set from the arguments specified in the method calls. -In addition, defines a `Scrolled` event that is fired to indicate that scrolling occurred. The `ItemsViewScrolledEventArgs` object that accompanies the `Scrolled` event has many properties. For more information, see [Detect scrolling](#detect-scrolling). +In addition, defines a event that is fired to indicate that scrolling occurred. The object that accompanies the event has many properties. For more information, see [Detect scrolling](#detect-scrolling). - also defines a `ItemsUpdatingScrollMode` property that represents the scrolling behavior of the when new items are added to it. For more information about this property, see [Control scroll position when new items are added](#control-scroll-position-when-new-items-are-added). + also defines a property that represents the scrolling behavior of the when new items are added to it. For more information about this property, see [Control scroll position when new items are added](#control-scroll-position-when-new-items-are-added). When a user swipes to initiate a scroll, the end position of the scroll can be controlled so that items are fully displayed. This feature is known as snapping, because items snap to position when scrolling stops. For more information, see [Snap points](#snap-points). @@ -24,7 +24,7 @@ When a user swipes to initiate a scroll, the end position of the scroll can be c ## Detect scrolling - defines a `Scrolled` event which is fired to indicate that scrolling occurred. The `ItemsViewScrolledEventArgs` class, which represents the object that accompanies the `Scrolled` event, defines the following properties: + defines a event which is fired to indicate that scrolling occurred. The class, which represents the object that accompanies the event, defines the following properties: - `HorizontalDelta`, of type `double`, represents the change in the amount of horizontal scrolling. This is a negative value when scrolling left, and a positive value when scrolling right. - `VerticalDelta`, of type `double`, represents the change in the amount of vertical scrolling. This is a negative value when scrolling upwards, and a positive value when scrolling downwards. @@ -34,7 +34,7 @@ When a user swipes to initiate a scroll, the end position of the scroll can be c - `CenterItemIndex`, of type `int`, is the index of the center item that's visible in the list. - `LastVisibleItemIndex`, of type `int`, is the index of the last item that's visible in the list. -The following XAML example shows a that sets an event handler for the `Scrolled` event: +The following XAML example shows a that sets an event handler for the event: ```xaml @@ -49,7 +49,7 @@ CollectionView collectionView = new CollectionView(); collectionView.Scrolled += OnCollectionViewScrolled; ``` -In this code example, the `OnCollectionViewScrolled` event handler is executed when the `Scrolled` event fires: +In this code example, the `OnCollectionViewScrolled` event handler is executed when the event fires: ```csharp void OnCollectionViewScrolled(object sender, ItemsViewScrolledEventArgs e) @@ -59,11 +59,11 @@ void OnCollectionViewScrolled(object sender, ItemsViewScrolledEventArgs e) ``` > [!IMPORTANT] -> The `Scrolled` event is fired for user initiated scrolls, and for programmatic scrolls. +> The event is fired for user initiated scrolls, and for programmatic scrolls. ## Scroll an item at an index into view -One `ScrollTo` method overload scrolls the item at the specified index into view. Given a object named , the following example shows how to scroll the item at index 12 into view: +One method overload scrolls the item at the specified index into view. Given a object named , the following example shows how to scroll the item at index 12 into view: ```csharp collectionView.ScrollTo(12); @@ -77,11 +77,11 @@ collectionView.ScrollTo(2, 1); ``` > [!NOTE] -> The `ScrollToRequested` event is fired when the `ScrollTo` method is invoked. +> The event is fired when the method is invoked. ## Scroll an item into view -Another `ScrollTo` method overload scrolls the specified item into view. Given a object named , the following example shows how to scroll the Proboscis Monkey item into view: +Another method overload scrolls the specified item into view. Given a object named , the following example shows how to scroll the Proboscis Monkey item into view: ```csharp MonkeysViewModel viewModel = BindingContext as MonkeysViewModel; @@ -99,11 +99,11 @@ collectionView.ScrollTo(monkey, group); ``` > [!NOTE] -> The `ScrollToRequested` event is fired when the `ScrollTo` method is invoked. +> The event is fired when the method is invoked. ## Disable scroll animation -A scrolling animation is displayed when scrolling an item into view. However, this animation can be disabled by setting the `animate` argument of the `ScrollTo` method to `false`: +A scrolling animation is displayed when scrolling an item into view. However, this animation can be disabled by setting the `animate` argument of the method to `false`: ```csharp collectionView.ScrollTo(monkey, animate: false); @@ -111,7 +111,7 @@ collectionView.ScrollTo(monkey, animate: false); ## Control scroll position -When scrolling an item into view, the exact position of the item after the scroll has completed can be specified with the `position` argument of the `ScrollTo` methods. This argument accepts a `ScrollToPosition` enumeration member. +When scrolling an item into view, the exact position of the item after the scroll has completed can be specified with the `position` argument of the methods. This argument accepts a enumeration member. ### MakeVisible @@ -126,7 +126,7 @@ This example code results in the minimal scrolling required to scroll the item i :::image type="content" source="media/scrolling/scrolltoposition-makevisible.png" alt-text="Screenshot of a CollectionView vertical list with ScrollToPosition.MakeVisible."::: > [!NOTE] -> The `ScrollToPosition.MakeVisible` member is used by default, if the `position` argument is not specified when calling the `ScrollTo` method. +> The `ScrollToPosition.MakeVisible` member is used by default, if the `position` argument is not specified when calling the method. ### Start @@ -166,13 +166,13 @@ This example code results in the item being scrolled to the end of the view: ## Control scroll position when new items are added - defines a `ItemsUpdatingScrollMode` property, which is backed by a bindable property. This property gets or sets a `ItemsUpdatingScrollMode` enumeration value that represents the scrolling behavior of the when new items are added to it. The `ItemsUpdatingScrollMode` enumeration defines the following members: + defines a property, which is backed by a bindable property. This property gets or sets a enumeration value that represents the scrolling behavior of the when new items are added to it. The enumeration defines the following members: - `KeepItemsInView` keeps the first item in the list displayed when new items are added. - `KeepScrollOffset` ensures that the current scroll position is maintained when new items are added. - `KeepLastItemInView` adjusts the scroll offset to keep the last item in the list displayed when new items are added. -The default value of the `ItemsUpdatingScrollMode` property is `KeepItemsInView`. Therefore, when new items are added to a the first item in the list will remain displayed. To ensure that the last item in the list is displayed when new items are added, set the `ItemsUpdatingScrollMode` property to `KeepLastItemInView`: +The default value of the property is `KeepItemsInView`. Therefore, when new items are added to a the first item in the list will remain displayed. To ensure that the last item in the list is displayed when new items are added, set the property to `KeepLastItemInView`: ```xaml @@ -191,7 +191,7 @@ CollectionView collectionView = new CollectionView ## Scroll bar visibility - defines `HorizontalScrollBarVisibility` and `VerticalScrollBarVisibility` properties, which are backed by bindable properties. These properties get or set a `ScrollBarVisibility` enumeration value that represents when the horizontal, or vertical, scroll bar is visible. The `ScrollBarVisibility` enumeration defines the following members: + defines `HorizontalScrollBarVisibility` and `VerticalScrollBarVisibility` properties, which are backed by bindable properties. These properties get or set a enumeration value that represents when the horizontal, or vertical, scroll bar is visible. The enumeration defines the following members: - `Default` indicates the default scroll bar behavior for the platform, and is the default value for the `HorizontalScrollBarVisibility` and `VerticalScrollBarVisibility` properties. - `Always` indicates that scroll bars will be visible, even when the content fits in the view. @@ -201,8 +201,8 @@ CollectionView collectionView = new CollectionView When a user swipes to initiate a scroll, the end position of the scroll can be controlled so that items are fully displayed. This feature is known as snapping, because items snap to position when scrolling stops, and is controlled by the following properties from the `ItemsLayout` class: -- `SnapPointsType`, of type `SnapPointsType`, specifies the behavior of snap points when scrolling. -- `SnapPointsAlignment`, of type `SnapPointsAlignment`, specifies how snap points are aligned with items. +- `SnapPointsType`, of type , specifies the behavior of snap points when scrolling. +- `SnapPointsAlignment`, of type , specifies how snap points are aligned with items. These properties are backed by objects, which means that the properties can be targets of data bindings. @@ -211,7 +211,7 @@ These properties are backed by o ### Snap points type -The `SnapPointsType` enumeration defines the following members: +The enumeration defines the following members: - `None` indicates that scrolling does not snap to items. - `Mandatory` indicates that content always snaps to the closest snap point to where scrolling would naturally stop, along the direction of inertia. @@ -223,7 +223,7 @@ By default, the `SnapPointsType` property is set to `SnapPointsType.None`, which ### Snap points alignment -The `SnapPointsAlignment` enumeration defines `Start`, `Center`, and `End` members. +The enumeration defines `Start`, `Center`, and `End` members. > [!IMPORTANT] > The value of the `SnapPointsAlignment` property is only respected when the `SnapPointsType` property is set to `Mandatory`, or `MandatorySingle`.