/// <summary> /// Proxy to the AddTaskCommand. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void AddTask(object sender, EventArgs e) { var elementToUpdate = (Control)FocusManager.GetFocusedElement(); BindingUpdateHelper.RefreshBinding(elementToUpdate); var viewModel = (AddTaskViewModel)DataContext; viewModel.AddTaskCommand.Execute(); // Fixme : Delegate this to a dedicated Service in the Command Handler. GoBack(); }
private void ValidateModifications(object sender, EventArgs eventArgs) { var elementToUpdate = (Control)FocusManager.GetFocusedElement(); // If something has the focus, and therefore, needs to have a workaround applied for the unfriendly behavior of the ApplicationBar concerning the Bindings. ( remember ? the focus is not lost when clicking the ApplicationBar, resulting in the binding not being updated as it's done on loosing focus. if (elementToUpdate != null) { BindingUpdateHelper.RefreshBinding(elementToUpdate); } var viewModel = (EditTaskViewModel)DataContext; viewModel.ValidateEditionCommand.Execute(null); GoBack(); }
private void ApplyTaskListChanges(object sender, EventArgs e) { var viewModel = (EditListsViewModel)DataContext; // If we were in edition now untill now : if (viewModel.IsEditing) { // HACK: an other way of doing, if we don't want to use the commandParameter, but we have to refresh the bindings manually // ( and specify the UI Element type to refresh, which kind of defeats the point ) because the Application bar is not a managed UI, it's part // of the native UI Chrome, and thus, doesn't remove the focus from the textbox. And Silverlight doesn't provide a strategy of bindings which will get it updated on each keystroke... // so, now we're left with the responsibility to make sure the bindings are refreshed before using the bound value... Not so great, I'd say ! var focused = FocusManager.GetFocusedElement() as Control; if (focused != null) { BindingUpdateHelper.RefreshBinding(focused); } var commandParameter = viewModel.CurrentTaskList; viewModel.ApplyTaskListChangesCommand.Execute(); // Add the buttons for the consultation view. InsertDefaultButtons(); } else { // the delete button is always at the last position. // Remove buttons for the consultation view ApplicationBar.Buttons.Remove(_deleteButton); // Add the buttons for the edition view. ApplicationBar.Buttons.Insert(0, _applyButton); } // Let's set the current view mode to edition or consultation. //viewModel.IsEditing = !viewModel.IsEditing; }