using System.Diagnostics; using System.Reactive.Disposables; using System.Windows; using Intromat.ViewModels; using ReactiveUI; namespace Intromat.Views { /// /// Interaction logic for UndoRedoView.xaml /// public partial class UndoRedoView : IViewFor { public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register(nameof(ViewModel), typeof(UndoRedoViewModel), typeof(UndoRedoView), new PropertyMetadata(null)); public UndoRedoView() { InitializeComponent(); this.WhenActivated(d => { Debug.Assert(ViewModel != null, nameof(ViewModel) + " != null"); this.BindCommand(ViewModel, vm => vm.UndoCommand, v => v.undoButton).DisposeWith(d); this.BindCommand(ViewModel, vm => vm.RedoCommand, v => v.redoButton).DisposeWith(d); }); } public UndoRedoViewModel? ViewModel { get => (UndoRedoViewModel?)GetValue(ViewModelProperty); set => SetValue(ViewModelProperty, value); } object? IViewFor.ViewModel { get => ViewModel; set => ViewModel = (UndoRedoViewModel?)value; } } }