0
votes

I have a simple window with a simple DataGrid on it. The window has a ViewModel which contains a public property ObservableCollection that I use for binding the ItemsSource. This is the code that I use. Very, very basic.

PluginsView pv = new PluginsView();
pv.ShowDialog();

This is the XAML of my DataGrid which gets populated. I have tried also with Mode=TwoWay without any luck.

<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Plugins}"               
   <DataGrid.Columns>
      <DataGridTextColumn Binding="{Binding Name}" Header="Name"/>
      <DataGridTextColumn Binding="{Binding DllName}" Header="DllName"/>
   </DataGrid.Columns>
</DataGrid>

When I click on a cell to edit the data, I receive the following error and my program crashes. I don't use any styles. Everything is default. It crashes on pv.ShowDialog(); line.

Cannot set OverridesDefaultStyle property in the default Style.

I have tried anything that I know, but I can't solve this error. Can you please share some suggestions to try because this is getting ridiculous. Thank you.

1
The exception is: XamlParseException was unhandledAlexandru Dicu
How about when you use pv.Show()?Ramin
The same error. It does not matter if is Show() or ShowDialog(). I have tried also on another machine, with the same result, so I exclude that my NET Framework installation is broken.Alexandru Dicu

1 Answers

2
votes

I have found the problem. I had a global style for TextBox and when I was clicking on a datagrid cell, it tried to override the TextBox style of the DataGrid cell with the global one, causing that exception. Two days of work lost with this problem. SOLVED by setting a Key to the global style.