この記事では ユーザーによって RatingControl の評価値が変更されたことを知る方法について説明します。
環境
| 開発環境 | Microsoft Visual Studio Professional 2019 Preview Version 16.11.0 Preview 3.0 |
| Framework | Microsoft .NET Framework Version 4.8.04084 |
| その他 | Microsoft.Project Reunion 0.8.0-preview |
| Microsoft.ProjectReunion.Foundation 0.8.0-preview | |
| Microsoft.ProjectReunion.WinUI 0.8.0-preview | |
| Microsoft.UI.Xaml 2.6.1 |
評価値が変更されたことを知る
RatingControl で評価値が変更されると、ValueChanged プロパティが発生します。
以下は、評価値が変更された時に TextBlock に評価値を表示する例です。
XAML の例
<Window
x:Class="WinUISample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUISample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<RatingControl x:Name="myRating"
ValueChanged="myRating_ValueChanged"/>
<TextBlock x:Name="myTextBlock" />
</StackPanel>
</Window>
C#の例
private void myRating_ValueChanged(RatingControl sender, object args)
{
myTextBlock.Text = myRating.Value.ToString();
}
Please follow and like us:


コメント