avechuche
avechuche

Reputation: 1560

IsReadOnly = False with issue - WPF

I have a problem, I need some editable column in my grid, I do what I need, but when I set the IsReadOnly property to False on the grid, when loading the ItemSource, I get a phantom row. I already checked and the collection has the correct amount of items, is it a visual mistake?

<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

Upvotes: 0

Views: 133

Answers (1)

Shiglet
Shiglet

Reputation: 111

You should add the property CanUserAddRows="false" to delete the "phantom row".

Upvotes: 3

Related Questions