本記事の概要
ActivityIndicator は、アプリケーションが長いアクティビティに関与していることを示すコントロールです。
この記事では ActivityIndicator の基本使用方法について説明します。
公式サイト情報はコチラを参照してください。
ActivityIndicator の基本使用方法
XAML で ActivityIndicator を作成するには <ActivityIndicator> を使用します。
進捗を表すアニメーションを表示する場合は IsRunning プロパティに True を設定します。また進捗を表すリングの色は Color プロパティで指定します。
XAML の例
以下の例では、ActivityIndicator の色を OrangeRed にし、IsRunning プロパティに True を設定してアニメーションを開始します。
XAML の例
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiAppSample.MainPage">
<VerticalStackLayout>
<ActivityIndicator IsRunning="True" Color="OrangeRed" />
</VerticalStackLayout>
</ContentPage>
C# の例
以下は 先ほどのXAML の例を コードビハインドで行う例です。
C# の例
public MainPage()
{
InitializeComponent();
myActivityIndicator.Color = Colors.OrangeRed;
myActivityIndicator.IsRunning = true;
}
XAML の例
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiAppSample.MainPage">
<VerticalStackLayout>
<ActivityIndicator x:Name="myActivityIndicator" />
</VerticalStackLayout>
</ContentPage>
.NET MAUI Tips
本サイトでまとめている .NET MAUI Tips の一覧はこちらから確認できます。
Please follow and like us:


コメント