Reputation: 1703
I use the following code and for example when the collection is field with data like with 2 item I see in the screen 2 rows with data and one more empty line at the end of the list.
How can I omit this last empty line? The collection are having just 2 entries. The collection items are having just 2 entries.
<DataGrid RowHeaderWidth="0" ItemsSource="{Binding Items}" AutoGenerateColumns="False">
<!--<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightBlue" />
</DataGrid.Resources>-->
<DataGrid.Columns>
<DataGridTemplateColumn Header="1" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Column1, UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding Column2}" Header="2" Width="*" />
<DataGridTextColumn Binding="{Binding Column3}" Header="3" Width="*" />
<DataGridTextColumn Binding="{Binding Column4}" Header="4" Width="*" />
<DataGridTextColumn Binding="{Binding Column5}" Header="5" Width="*" />
</DataGrid.Columns>
</DataGrid>
Upvotes: 1
Views: 1219
Reputation: 22702
Try for CanUserAddRows
set false, the registered default is true:
<DataGrid Name="MyDataGrid"
CanUserAddRows="False" ... />
Quote from MSDN
:
When this property is set to true a blank row is displayed at the bottom of the DataGrid. A user can enter a new item into the blank row. Adding a new row adds an item to the ItemsSource.
Upvotes: 3