1public class MainControlViewModel : BindableBase
2{34int m_state;5 public int SetupState
6{7 get {return m_state;}8 set {SetProperty(ref m_state, value);}9}1011 public ReactiveCommand InteractiveCommand { get;}1213 public MainControlViewModel()14{15 SetupState =1;16 InteractiveCommand = new ReactiveCommand();17 InteractiveCommand.Subscribe(_ =>18{19 SetupState++;20});21}22}23
補足情報(FW/ツールのバージョンなど)
Visual Studio 2017 Community
.NET Framework 4.6.1
Prism v7.1.0.431
1using System;2using System.Collections.Generic;3using System.Globalization;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7using System.Windows;8using System.Windows.Data;9using System.Windows.Media;1011namespace WpfApp1
12{13 public class SetupStateColorConverter : DependencyObject, IValueConverter
14{15 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)16{17if(!(value is int intValue))return NormalBrush;18if(!(parameter is string strParam))return NormalBrush;19if(!(int.TryParse(strParam, out int intParam)))return NormalBrush;20if(intValue != intParam)return NormalBrush;21return HighlightBrush;22}2324 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)25{26 throw new NotImplementedException();27}2829#regionNormalBrush30 public Brush NormalBrush
31{32 get {return(Brush)GetValue(NormalBrushProperty);}33 set {SetValue(NormalBrushProperty, value);}34}3536 public static readonly DependencyProperty NormalBrushProperty =37 DependencyProperty.Register(38nameof(NormalBrush),39typeof(Brush),40typeof(SetupStateColorConverter),41 new PropertyMetadata(new SolidColorBrush(Colors.Black)));42#endregion4344#regionHighlightBrush45 public Brush HighlightBrush
46{47 get {return(Brush)GetValue(HighlightBrushProperty);}48 set {SetValue(HighlightBrushProperty, value);}49}5051 public static readonly DependencyProperty HighlightBrushProperty =52 DependencyProperty.Register(53nameof(HighlightBrush),54typeof(Brush),55typeof(SetupStateColorConverter),56 new PropertyMetadata(new SolidColorBrush(Colors.Red)));57#endregion58}59}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/18 23:43
2019/06/19 11:22
2019/06/19 11:47 編集
2019/06/21 12:46