private void OnSetResolutionCommand(object sender, ConsoleCommandArgs e) { UISynchronizationContext.ExecuteOnUIContext(() => { var window = Resolve <IShell>() as Window; if (!e.Arguments.ContainsKey("/r")) { e.Result.Add("You must specify the /r argument."); e.Handled = false; return; } var res = e.Arguments["/r"]; if (res.ToLower() == "fullscreen") { window.WindowState = WindowState.Maximized; } else { var resWH = res.Split('x'); window.WindowState = WindowState.Normal; window.Height = double.Parse(resWH[0]); window.Width = double.Parse(resWH[1]); } }); e.Handled = true; }
/// <inheritdoc /> public virtual void UpdateCanExecute() { UISynchronizationContext.ExecuteOnUIContext(() => { bool canExecute = true; foreach (var property in _observedProperties) { if (!property.Validate()) { canExecute = false; break; } } if (_canExecute != canExecute) { _canExecute = canExecute; CanExecuteChanged?.Invoke(this, EventArgs.Empty); } }); }
/// <summary> /// Executes and action on the UI SynchronizationContext /// </summary> /// <param name="action"></param> protected void ExecuteOnUIContext(Action action) { UISynchronizationContext.ExecuteOnUIContext(action); }