How to remove the default empty row from the WPF data grid

Aug 25, 2009 at 12:32 PM


Does anyone know how I can remove the default empty row added to the WPF datagrid?

Thanks in advance



Aug 25, 2009 at 9:53 PM

Hi Kanchanaw,

When are you seeing a default empty row?  Can you attach your application to this thread?



Aug 26, 2009 at 5:35 AM

This is the datagrid that i am using in my application  and always there is a empty row in the grid with two combo boxes.

I am not able to insert the screen shot of the data grid here  :(

<dg:DataGrid x:Name="sorterFieldsDataGrid" Grid.Row="1" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True">
                <!-- TODO: localization of the Header values -->
                <dg:DataGridComboBoxColumn Header="Field" SelectedValueBinding="{Binding Path=Value.Field}">
                        <Style TargetType="{x:Type ComboBox}">
                            <EventSetter Event="SelectionChanged" Handler="SortFieldChanged" />

                <dg:DataGridComboBoxColumn Header="Order" SelectedValueBinding="{Binding Path=Value.NaturalOrder, Converter={StaticResource BoolConverter}}">


Aug 26, 2009 at 9:51 AM

Change  CanUserAddRows="True" to "false" (CanUserAddRows="False").  And add the rows manually when needed.

Aug 26, 2009 at 11:07 AM

Thanks it worked  :)


Sep 1, 2009 at 3:24 AM

In the above data grid When i try to capture the SelectionChanged event of the first DataGridComboBoxColumn in SortFieldChanged event the selection changed event gets fired when the mousefocus is set to the combobox and when the expand the dropdown list and when the an item is selected.

But When i try to iterate the items in the combo box the newly selected value is not updated and it will be updated when set the mousefocus 2ndtime to the combo box after actually chaning the value from in the first time.

Is this the default behaviour for DataGridComboBoxColum? How can i  capture the selection change event when only the selected item is changed ?