WPF:导航到其他页面时,“当SelectionUnit为FullRow时,无法更改单元格选择”

时间:2017-01-18 13:07:41

标签: c# wpf datagrid

我有一个简单的DataGrid

<DataGrid AutoGenerateColumns="False" 
          ItemsSource="{Binding Items, Mode=TwoWay}"               
          CanUserAddRows="True" CanUserDeleteRows="True" 

          SelectionMode="Single" 
          SelectedItem="{Binding SelectedItem, Mode=TwoWay}" SelectionUnit="FullRow" >
      <DataGridTextColumn Header="Name" 
                          Binding="{Binding Path=Name, Mode=TwoWay}" 
                          CellStyle="{StaticResource CellDefaultStyle}" />
</DataGrid>

我在Page的{​​{1}}上使用它。当我打开页面并导航到另一个页面时,一切都很好。

但是当我打开页面并在DataGrid中选择一行然后导航到另一个页面时,我收到错误:

  

当SelectionUnit为FullRow时,无法更改单元格选择。

但我想保留NavigationWindow选择单元。

1 个答案:

答案 0 :(得分:0)

原来是我在某处下载的CellStyle来美化我的行。删除属性后

CellStyle="{StaticResource CellDefaultStyle}"

它正常工作。

相关问题