35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
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(_checkBoxValue), Type = typeof(CheckBox))]
|
|
[TemplatePart(Name = nameof(_textBlockValue), Type = typeof(TextBlock))]
|
|
public class BooleanExpressionEditorView : EditorViewBase<BooleanExpressionEditorViewModel>
|
|
{
|
|
private CheckBox _checkBoxValue = null!;
|
|
private TextBlock _textBlockValue = null!;
|
|
|
|
public BooleanExpressionEditorView()
|
|
{
|
|
DefaultStyleKey = typeof(BooleanExpressionEditorView);
|
|
|
|
this.WhenActivated(d =>
|
|
{
|
|
this.OneWayBind(ViewModel, vm => vm.CustomValue, v => v._textBlockValue.Text, b => b.ToString()).DisposeWith(d);
|
|
this.Bind(ViewModel, vm => vm.CustomValue, v => v._checkBoxValue.IsChecked).DisposeWith(d);
|
|
});
|
|
}
|
|
|
|
public override void OnApplyTemplate()
|
|
{
|
|
base.OnApplyTemplate();
|
|
_checkBoxValue = (CheckBox)GetTemplateChild(nameof(_checkBoxValue))!;
|
|
_textBlockValue = (TextBlock)GetTemplateChild(nameof(_textBlockValue))!;
|
|
}
|
|
}
|
|
} |