I have a data grid in my WPF application window and the data is tied to the observed collection. In the DataGrid, I set the property CanUserDeleteRows=True, and I can delete the row by clicking the "Delete" button on the keyboard.
It does not look intuitive to me. I want to save an extra column that has a delete button when clicked, which row should be deleted. (something like what can be done in ItemTemplate in ASP.NET)
<DataGrid x:Name="dgrQuestions" AutoGenerateColumns="False" Height="224" HorizontalAlignment="Left" Margin="42,73,0,0" VerticalAlignment="Top" Width="663" ItemsSource="{Binding QueList}" CanUserAddRows="True" CanUserDeleteRows="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Qu" Binding="{Binding Path=Que, UpdateSourceTrigger=PropertyChanged}"/>
<DataGridTextColumn Header="An" Binding="{Binding Path=Ans, UpdateSourceTrigger=PropertyChanged}"/>
<DataGridTextColumn Header="Hi" Binding="{Binding Path=Hi, UpdateSourceTrigger=PropertyChanged}"/>
</DataGrid.Columns>
How to get this function to delete rows using buttoninside datagrid itself
source
share