首页 文章

单击单击时WPF DataGrid崩溃

提问于
浏览
0

我有一个简单的窗口,上面有一个简单的DataGrid . 该窗口有一个ViewModel,它包含一个公共属性ObservableCollection,我用它来绑定ItemsSource . 这是我使用的代码 . 非常,非常基本 .

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

这是我的DataGrid的XAML,它被填充 . 我也试过Mode = TwoWay而没有任何运气 .

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

当我单击一个单元格来编辑数据时,我收到以下错误,我的程序崩溃了 . I don't use any styles. 一切都是默认的 . 它崩溃了 pv.ShowDialog(); 行 .

Cannot set OverridesDefaultStyle property in the default Style.

我尝试过任何我知道的东西,但我无法解决这个错误 . 请你分享一些尝试,因为这太荒谬了 . 谢谢 .

1 回答

  • 2

    我发现了这个问题 . 我有一个TextBox的全局样式,当我点击一个datagrid单元格时,它试图用全局样式覆盖DataGrid单元格的TextBox样式,从而导致该异常 . 这个问题失去了两天的工作 . 通过设置全局样式的键来解决 .

相关问题