Great question Johan! I assume that since you are not explicitly providing it with a CollectionViewSource , the automatically generated cvs of the DataGrid are shared between them, as you are referring to the same source.
Therefore, the last installation wins when you perform two IsReadOnly and are a common source, both DataGrid show the same effect.
To confirm my assumption, I used this code, and DataGrids behaves as you would expect when you offer them an explicit CollectionViewSource to work with.
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <CollectionViewSource Source="{Binding Persons}" x:Key="cvs1" /> <CollectionViewSource Source="{Binding Persons}" x:Key="cvs2" /> </Window.Resources> <DockPanel> <DataGrid ItemsSource="{Binding Source={StaticResource ResourceKey=cvs1}}" IsReadOnly="False" CanUserAddRows="True" /> <DataGrid ItemsSource="{Binding Source={StaticResource ResourceKey=cvs2}}" IsReadOnly="True" /> </DockPanel> </Window>
EDIT: Further testing indicates that the behavior can simply be called odd! I can't explain why this produces three read-only DGs
<DataGrid ItemsSource="{Binding Persons}" IsReadOnly="True" /> <DataGrid ItemsSource="{Binding Persons}" IsReadOnly="False" /> <DataGrid ItemsSource="{Binding Persons}" IsReadOnly="True" />
but this creates an alternate readonly and editable DG:
<DataGrid ItemsSource="{Binding Persons}" IsReadOnly="True" /> <DataGrid ItemsSource="{Binding Persons}" IsReadOnly="False" /> <DataGrid ItemsSource="{Binding Persons}" IsReadOnly="True" /> <DataGrid ItemsSource="{Binding Persons}" IsReadOnly="False" />
So, I think the aforementioned CVS is best described as a workaround for this odd behavior, so you can achieve what you really want.
EDIT 2: After even more combinations of true false, the only thing I noticed is that if the Last IsReadOnly in DataGrid parameter is set to True, all other DataGrids become read-only. But if the latter is set to false, then all other DataGrids behave in accordance with their IsReadOnly setting. This may be due to this MSDN bit.
If a conflict exists between the settings at the DataGrid, column, or cell levels, a value of true takes precedence over a value of false.