■ RatingControl 엘리먼트의 Caption/IsClearEnabled/PlaceholderValue 속성을 사용하는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<?xml version="1.0" encoding="utf-8"?> <Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="TestProject"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <RatingControl Name="ratingControl1" HorizontalAlignment="Center" Caption="312 ratings" IsClearEnabled="{x:Bind isClearEnabledCheckBox.IsChecked.Value, Mode=OneWay}" IsReadOnly="{x:Bind isReadOnlyCheckBox.IsChecked.Value, Mode=OneWay}" /> <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" FontWeight="Bold" Text="{x:Bind ratingControl1.Value, Mode=OneWay}" /> <CheckBox Name="isClearEnabledCheckBox" HorizontalAlignment="Center" Margin="0 10 0 0" Content="IsClearEnabled" /> <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" Text="평가를 삭제하려면 왼쪽으로 스와이프 해주시기 바랍니다." TextWrapping="WrapWholeWords" /> <CheckBox Name="isReadOnlyCheckBox" HorizontalAlignment="Center" Margin="0 10 0 0" Content="IsReadOnly" /> <RatingControl Name="RatingControl2" HorizontalAlignment="Center" Margin="0 30 0 0" PlaceholderValue="{x:Bind slider.Value, Mode=TwoWay}" /> <Slider Name="slider" HorizontalAlignment="Center" Margin="0 10 0 0" Header="PlaceholderValue" Minimum="0" Maximum="5" SmallChange="0.5" StepFrequency="0.5" IsFocusEngagementEnabled="False" /> </StackPanel> </Window> |
▶ MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; namespace TestProject { /// <summary> /// 메인 윈도우 /// </summary> public sealed partial class MainWindow : Window { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainWindow() /// <summary> /// 생성자 /// </summary> public MainWindow() { InitializeComponent(); this.ratingControl1.ValueChanged += ratingControl1_ValueChanged; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 평가 컨트롤 1 값 변경시 처리하기 - ratingControl1_ValueChanged(sender, e) /// <summary> /// 평가 컨트롤 1 값 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void ratingControl1_ValueChanged(RatingControl sender, object e) { this.ratingControl1.Caption = "Your rating"; } #endregion } } |