using System.Reactive.Disposables; using System.Windows; using System.Windows.Controls; using Intromat.Interfaces; using Intromat.ViewModels.Editors; using ReactiveUI; namespace Intromat.Views.Editors { [TemplatePart(Name = nameof(_sliderValue), Type = typeof(Slider))] [TemplatePart(Name = nameof(_textBoxValue), Type = typeof(TextBox))] public class IntegerExpressionEditorView : EditorViewBase { private Slider _sliderValue = null!; private TextBox _textBoxValue = null!; public IntegerExpressionEditorView() { DefaultStyleKey = typeof(IntegerExpressionEditorView); this.WhenActivated(d => { this.Bind(ViewModel, vm => vm.CustomValue, v => v._textBoxValue.Text).DisposeWith(d); this.Bind(ViewModel, vm => vm.CustomValue, v => v._sliderValue.Value, i => i, v => (int)v).DisposeWith(d); this.Bind(ViewModel, vm => vm.MinValue, v => v._sliderValue.Minimum, i => i, v => (int)v).DisposeWith(d); this.Bind(ViewModel, vm => vm.MaxValue, v => v._sliderValue.Maximum, i => i, v => (int)v).DisposeWith(d); }); } public override void OnApplyTemplate() { base.OnApplyTemplate(); _sliderValue = (Slider)GetTemplateChild(nameof(_sliderValue))!; _textBoxValue = (TextBox)GetTemplateChild(nameof(_textBoxValue))!; } } }