port from perforce
This commit is contained in:
37
intromat/Intromat/Views/Editors/FloatValueEditorView.cs
Normal file
37
intromat/Intromat/Views/Editors/FloatValueEditorView.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
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 FloatValueEditorView : EditorViewBase<FloatValueEditorViewModel>
|
||||
{
|
||||
private Slider _sliderValue = null!;
|
||||
private TextBox _textBoxValue = null!;
|
||||
|
||||
public FloatValueEditorView()
|
||||
{
|
||||
DefaultStyleKey = typeof(FloatValueEditorView);
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
this.Bind(ViewModel, vm => vm.Value, v => v._textBoxValue.Text).DisposeWith(d);
|
||||
this.Bind(ViewModel, vm => vm.Value, v => v._sliderValue.Value, i => i, v => (float)v).DisposeWith(d);
|
||||
this.Bind(ViewModel, vm => vm.MinValue, v => v._sliderValue.Minimum, i => i, v => (float)v).DisposeWith(d);
|
||||
this.Bind(ViewModel, vm => vm.MaxValue, v => v._sliderValue.Maximum, i => i, v => (float)v).DisposeWith(d);
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
_sliderValue = (Slider)GetTemplateChild(nameof(_sliderValue))!;
|
||||
_textBoxValue = (TextBox)GetTemplateChild(nameof(_textBoxValue))!;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user