slider.Value를 바인딩 할 때 지정한 Converter를 사용하라
라는 의미
<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" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <Grid.Resources> <local:Light x:Key="LightConvert"/> </Grid.Resources> <StackPanel> <TextBlock Text="TextBlock"/> <TextBox Text="TextBox" Background="{Binding Value, ElementName=slider, Converter={StaticResource LightConvert}}"/> <ProgressBar Value="50" Width="60" Height="20"/> <Slider Value="5" Width="60" x:Name="slider"/> <PasswordBox Password="Secret"/> </StackPanel> </Grid> </Window>
namespace WpfApp1 { public class Light : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo cluture) { var iValue = (double)value; if (iValue > 7) { return "Red"; } else if (iValue < 7 && iValue >= 4) { return "Yellow"; } else { return "Green"; } } } }
"WPF MVVM 일주일 만에 배우기" 를 참고 하였습니다
'Develop' 카테고리의 다른 글
wpf textbox twoway (0) | 2018.12.13 |
---|---|
c# interface method 정의 (0) | 2018.12.04 |
perforce ignore (0) | 2018.09.05 |
python AES 암호화 (0) | 2018.05.17 |
nodejs zip (0) | 2018.02.27 |