// attempt to get a simpler interface public OkCancelWindow(object content, IOKCancelViewModel viewModel) { Console.WriteLine("okcancel ctor-before"); // copied from default ctor due to https://github.com/nventive/Uno/issues/61 InitializeComponent(); CancelCommand = new HseDelegateCommand(o => Close()); GotFocus += OkCancelWindowGotFocus; Console.WriteLine("okcancel ctor"); OkCommand = new HseDelegateCommand(_ => { Console.WriteLine("ok command"); if (viewModel.OK(this)) { Close(); viewModel.Dispose(); } }, viewModel.OkCanExecute); CancelCommand = new HseDelegateCommand(_ => { if (viewModel.Cancel()) { Close(); viewModel.Dispose(); } }, viewModel.CancelCanExecute); viewModel.OkCommand = OkCommand; viewModel.CancelCommand = CancelCommand; WindowMessage = content; SetBinding(OkTextProperty, new Binding { Path = new PropertyPath("OkText") }); SetBinding(CancelTextProperty, new Binding { Path = new PropertyPath("CancelText") }); DataContext = viewModel; viewModel.View = this; }
/// <summary> /// /// </summary> public OkCancelWindow() { InitializeComponent(); CancelCommand = new HseDelegateCommand(o => Close()); GotFocus += OkCancelWindowGotFocus; }