Ok, in order to try to find an answer for this question I have made an even simpler project, using the AdventureWorks database.
I created a Model from the Vendor and PurchaseOrderHeader tables - added them as a datasource to the project, and have the following code:
XAML:
<Windowx:Class="EFDbContextTest.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow"Height="569"Width="1130"mc:Ignorable="d"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:my="clr-namespace:EFDbContextTest;assembly=EFDbContextTest"Loaded="Window_Loaded"><Window.Resources><CollectionViewSourcex:Key="vendorViewSource"d:DesignSource="{d:DesignInstance my:Vendor, CreateList=True}"/><CollectionViewSourcex:Key="vendorPurchaseOrderHeadersViewSource"Source="{Binding Path=PurchaseOrderHeaders, Source={StaticResource vendorViewSource}}"/></Window.Resources><GridDataContext="{StaticResource vendorViewSource}"><DataGridAutoGenerateColumns="False"EnableRowVirtualization="True"Height="200"HorizontalAlignment="Left"ItemsSource="{Binding}"Margin="12,12,0,0"Name="vendorDataGrid"RowDetailsVisibilityMode="VisibleWhenSelected"VerticalAlignment="Top"Width="1084"IsSynchronizedWithCurrentItem="True"><DataGrid.Columns><DataGridTextColumnx:Name="accountNumberColumn"Binding="{Binding Path=AccountNumber}"Header="Account Number"Width="SizeToHeader"/><DataGridCheckBoxColumnx:Name="activeFlagColumn"Binding="{Binding Path=ActiveFlag}"Header="Active Flag"Width="SizeToHeader"/><DataGridTextColumnx:Name="creditRatingColumn"Binding="{Binding Path=CreditRating}"Header="Credit Rating"Width="SizeToHeader"/><DataGridTemplateColumnx:Name="modifiedDateColumn"Header="Modified Date"Width="SizeToHeader"><DataGridTemplateColumn.CellTemplate><DataTemplate><DatePickerSelectedDate="{Binding Path=ModifiedDate, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}"/></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn><DataGridTextColumnx:Name="nameColumn"Binding="{Binding Path=Name}"Header="Name"Width="SizeToHeader"/><DataGridCheckBoxColumnx:Name="preferredVendorStatusColumn"Binding="{Binding Path=PreferredVendorStatus}"Header="Preferred Vendor Status"Width="SizeToHeader"/><DataGridTextColumnx:Name="purchasingWebServiceURLColumn"Binding="{Binding Path=PurchasingWebServiceURL}"Header="Purchasing Web Service URL"Width="SizeToHeader"/><DataGridTextColumnx:Name="vendorIDColumn"Binding="{Binding Path=VendorID}"Header="Vendor ID"Width="SizeToHeader"/></DataGrid.Columns></DataGrid><DataGridAutoGenerateColumns="False"EnableRowVirtualization="True"Height="200"HorizontalAlignment="Left"ItemsSource="{Binding Source={StaticResource vendorPurchaseOrderHeadersViewSource}}"Margin="12,218,0,0"Name="purchaseOrderHeadersDataGrid"RowDetailsVisibilityMode="VisibleWhenSelected"VerticalAlignment="Top"Width="1084"IsSynchronizedWithCurrentItem="True"><DataGrid.Columns><DataGridTextColumnx:Name="employeeIDColumn"Binding="{Binding Path=EmployeeID}"Header="Employee ID"Width="SizeToHeader"/><DataGridTextColumnx:Name="freightColumn"Binding="{Binding Path=Freight}"Header="Freight"Width="SizeToHeader"/><DataGridTemplateColumnx:Name="modifiedDateColumn1"Header="Modified Date"Width="SizeToHeader"><DataGridTemplateColumn.CellTemplate><DataTemplate><DatePickerSelectedDate="{Binding Path=ModifiedDate, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}"/></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn><DataGridTemplateColumnx:Name="orderDateColumn"Header="Order Date"Width="SizeToHeader"><DataGridTemplateColumn.CellTemplate><DataTemplate><DatePickerSelectedDate="{Binding Path=OrderDate, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}"/></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn><DataGridTextColumnx:Name="purchaseOrderIDColumn"Binding="{Binding Path=PurchaseOrderID}"Header="Purchase Order ID"Width="SizeToHeader"/><DataGridTextColumnx:Name="revisionNumberColumn"Binding="{Binding Path=RevisionNumber}"Header="Revision Number"Width="SizeToHeader"/><DataGridTemplateColumnx:Name="shipDateColumn"Header="Ship Date"Width="SizeToHeader"><DataGridTemplateColumn.CellTemplate><DataTemplate><DatePickerSelectedDate="{Binding Path=ShipDate, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}"/></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn><DataGridTextColumnx:Name="shipMethodIDColumn"Binding="{Binding Path=ShipMethodID}"Header="Ship Method ID"Width="SizeToHeader"/><DataGridTextColumnx:Name="statusColumn"Binding="{Binding Path=Status}"Header="Status"Width="SizeToHeader"/><DataGridTextColumnx:Name="subTotalColumn"Binding="{Binding Path=SubTotal}"Header="Sub Total"Width="SizeToHeader"/><DataGridTextColumnx:Name="taxAmtColumn"Binding="{Binding Path=TaxAmt}"Header="Tax Amt"Width="SizeToHeader"/><DataGridTextColumnx:Name="totalDueColumn"Binding="{Binding Path=TotalDue}"Header="Total Due"Width="SizeToHeader"/><DataGridTextColumnx:Name="vendorIDColumn1"Binding="{Binding Path=VendorID}"Header="Vendor ID"Width="SizeToHeader"/></DataGrid.Columns></DataGrid></Grid></Window>
C#:
using System;using System.Collections.Generic;using System.Data.Entity;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;namespace EFDbContextTest {///<summary>/// Interaction logic for MainWindow.xaml///</summary>publicpartialclass MainWindow : Window { Entities _context = new Entities();public MainWindow() { InitializeComponent(); }privatevoid Window_Loaded(object sender, RoutedEventArgs e) { System.Windows.Data.CollectionViewSource vendorViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("vendorViewSource"))); _context.Vendors.Include("PurchaseOrderHeaders").Load(); vendorViewSource.Source = _context.Vendors.Local; } } }
So, both grids are on the Window, you can edit/delete/update the Master grid like there's no tomorrow - as soon as you try to click into any cell on the detail grid you get the error 'EditItem' is not allowed for this view.
I have to be missing something here, because this happens to me in several instances where I have a Master-Detail view using EF 4.1 - help!