public ComboBoxViewModelProperty(string prName, Action <string?> change, string current, string[] values, IViewPropertyValidator validator) : base(prName, change, validator) { this.current = current; var obs = new ObservableCollection <ComboBoxItem>(); var selectedIndex = 0; foreach (var v in values) { var cbi = new ComboBoxItem(v, v); if (v == current) { selectedIndex = obs.Count; } obs.Add(cbi); } Values = CollectionViewSource.GetDefaultView(obs); Values.MoveCurrentToPosition(selectedIndex); Values.CurrentChanged += OnValuesCurrentChanged; }
public ComboBoxViewModelProperty(string prName, Action <string?> change, string current, IEnumerable <FieldInfo> values, IViewPropertyValidator validator) : base(prName, change, validator) { this.current = current; var obs = new ObservableCollection <ComboBoxItem>(); var selectedIndex = 0; foreach (var item in values) { var name = item.Name; var display = item.GetCustomAttribute <DisplayAttribute>(); var disp = display?.GetName() ?? name; var cbi = new ComboBoxItem(name, disp); if (name == current) { selectedIndex = obs.Count; } obs.Add(cbi); } Values = CollectionViewSource.GetDefaultView(obs); Values.MoveCurrentToPosition(selectedIndex); Values.CurrentChanged += OnValuesCurrentChanged; }
internal GroupViewModelProperties([NotNull] string title, [NotNull] IViewModelProxy value, [NotNull] IViewPropertyValidator prValidator) : base(title, prValidator) { Title = title; this.value = value ?? throw new ArgumentNullException(nameof(value)); Properties = new ObservableCollection <ViewModelProperty>(); currentUICulture = Thread.CurrentThread.CurrentUICulture; proxy = value; proxy.PropertyViewUpdate += OnPropertyViewUpdate; proxy.PropertyChanged += OnPropertyChanged; }
public TextBoxViewModelProperty(string prName, string val, Action <string> change, IViewPropertyValidator validator) : base(prName, val, change, validator) { }