Exemplo n.º 1
0
 private void DataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
 {
     DinerMax3000.Business.MenuItem newMenuItem = e.Row.Item as DinerMax3000.Business.MenuItem;
     if (newMenuItem != null && e.EditAction == DataGridEditAction.Commit && e.Row.IsNewItem)
     {
         DinerMax3000.WPFClient.DinerMax3000ViewModel currentViewModel = (DinerMax3000.WPFClient.DinerMax3000ViewModel)DataContext;
         currentViewModel.NewMenuItems.Add(newMenuItem);
     }
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DinerMax3000.WPFClient.DinerMax3000ViewModel currentViewModel =
                (DinerMax3000.WPFClient.DinerMax3000ViewModel)DataContext;

            DinerMax3000.Business.MenuItem newMenuItem = currentViewModel.NewMenuItem;

            currentViewModel.SelectedMenu.SaveNewMenuItem(newMenuItem.Title, newMenuItem.Description, newMenuItem.Price);

            BindingOperations.GetBindingExpressionBase(cboAllMenus, ComboBox.ItemsSourceProperty).UpdateTarget();
        }