次の方法で共有


Windows での RefreshView のプル方向

この .NET マルチプラットフォーム アプリ UI (.NET MAUI) Windows プラットフォーム固有設定では、データを表示するスクロール可能なコントロールの向きに合わせて RefreshView のプル方向を変更できます。 これは、バインド可能な RefreshPullDirection プロパティをRefreshView.RefreshPullDirection列挙型の値に設定することにより、XAML で使用されます。

<ContentPage ...
             xmlns:windows="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;assembly=Microsoft.Maui.Controls">
    <RefreshView windows:RefreshView.RefreshPullDirection="LeftToRight"
                 IsRefreshing="{Binding IsRefreshing}"
                 Command="{Binding RefreshCommand}">
        <ScrollView>
            ...
        </ScrollView>
    </RefreshView>
 </ContentPage>

また、Fluent API を使用して C# から使用することもできます。

using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;
...
refreshView.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows>().SetRefreshPullDirection(RefreshPullDirection.LeftToRight);

RefreshView.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows> メソッドは、このプラットフォーム固有設定が Windows でのみ実行されるように指定します。 RefreshView.SetRefreshPullDirection メソッドは Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific 名前空間で、4 つの可能な値を提供する RefreshPullDirection 列挙型とともに RefreshView のプル方向を設定するために使われます。

  • LeftToRight は、左から右へのプルが更新を開始することを示します。
  • TopToBottom は、上から下へのプルが更新を開始し、RefreshView の既定のプル方向であることを示します。
  • RightToLeft は、右から左へのプルが更新を開始することを示します。
  • BottomToTop は、下から上へのプルが更新を開始することを示します。

さらに、GetRefreshPullDirection メソッドを使用して RefreshView の現在の RefreshPullDirection を返すことができます。

その結果、指定された RefreshViewRefreshPullDirectionに適用され、データが表示されるスクロール可能なコントロールの向きに合わせてプル方向を設定します。 次のスクリーンショットは、LeftToRight プル方向の RefreshView を示しています。

Screenshot of a RefreshView with a left to right pull direction, on Windows.

プル方向を変更すると、プログレス サークルの開始位置が自動的に回転し、矢印がプル方向に適した位置で開始されます。