public void Add() { ModalWorkItemDialog dialog = new ModalWorkItemDialog(); var coWorker = DataContext as CoWorker; var workItem = new WorkItem() { CoWorkerId = coWorker.CoWorkerId }; dialog.DataContext = workItem; dialog.ShowDialog(); }
public void Edit() { var coWorker = DataContext as CoWorker; ModalWorkItemDialog dialog = new ModalWorkItemDialog(); var workItem = new WorkItem(coWorker.WorkItems.SelectedItem); workItem.OperationState = OperationState.Edit; dialog.DataContext = workItem; //Get index so we know what to update later. int indexOf = coWorker.WorkItems.IndexOf(coWorker.WorkItems.SelectedItem); if (dialog.ShowDialog().IsTrue()) { coWorker.WorkItems[indexOf] = dialog.DataContext as WorkItem; } }