rksoftware

Visual Studio とか C# とかが好きです

WPF で ProgressRing

以前に WPF で ProgressBar で処理中を表現する記事を書きました。

しかし、モバイルOSの世界では一般的に Ring 表現ですし、Webサイトでも Ring 表現が多くなっています。
そんな最近はやりの ProgressRing ですが残念ながら WPF の標準コントロールにはありません。標準コントロールにはありませんが、良いライブラリがあるそうなので試してみます。

※参考 http://kenzauros.com/blog/progress-ring-in-wpf-with-mahapps-metro/

■ NuGet

NugGet から MahApps.Metro をインストールします。

■ XAML

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        mc:Ignorable="d"
        Title="MainWindow" Height="250" Width="400">
    <Grid>
        <mah:ProgressRing/>
    </Grid>
</Window>

f:id:rksoftware:20180925020411j:plain

追加したコードは2行だけです。

xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
<mah:ProgressRing/>

これだけで ProgressRing を表示できました。
MahApps.Metro には他にも多くのコントロールが含まれています。余裕のある時にでも確認してみると良さそうです。