I have a DataGrid with 4 columns, the first two of them are bound to an object. The other two are button columns are made like this
<DataGridTemplateColumn MaxWidth="100" Header="Delete">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="BtnDelete" CommandParameter="{Binding Path=Id}" Content="Delete" Click="BtnDeleteEmployee_Click" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
My Datagrid has CanUserAddRows="True" which always generates an empty row in the bottom of the grid. However, I would like the two buttons on the bottom row to be disabled until the other rows have been filled. As it is now, I'm (of course) getting a nullreferenceexception when I click the button.
I guess a solution would be to bind the button's IsEnabled property to
id>0
But how to do this, I am not sure.