IsReadOnly = False with issue - WPF

时间:2017-02-21 13:10:01

标签: c# wpf

我遇到了问题,我需要在网格中使用一些可编辑的列,我可以做我需要的,但是当我在网格上将IsReadOnly属性设置为False时,在加载ItemSource时,我获取幻像行。我已经检查过,并且收藏品中有正确数量的物品,这是一个视觉错误吗?

<DataGrid AlternationCount="2"
      SelectionMode="Single"
      SelectionUnit="FullRow"
      BorderThickness="0,3,0,3"
      AutoGenerateColumns="False"
      GridLinesVisibility="Horizontal"
      ItemsSource="{Binding Articles}"
      BorderBrush="{DynamicResource GrayBrush5}"
      AlternatingRowBackground="{DynamicResource GrayBrush5}"
      HorizontalGridLinesBrush="{StaticResource AccentColorBrush}">

      <DataGridTextColumn Width="100"
                          Header="Code"
                          IsReadOnly="True"
                          Binding="{Binding Code}" />  

enter image description here

1 个答案:

答案 0 :(得分:2)

你应该添加属性CanUserAddRows =&#34; false&#34;删除&#34;幻像行&#34;。