When I bind my ObservableCollection to my DataGrid with AutoGenerateColumns to true. I can double-click on the cell that I want to edit, and then I can edit the text that is in the cell.
But when I set AutoGenerateColumns to false and want to use a custom DataGridTextColumns , I can also double-click on the cell. But the text that was there is deleted, so I have an empty line instead of the one I wanted to edit a little.
Any ideas on this issue?
This is my DataGrid :
<DataGrid ItemsSource="{Binding Tasks}" Margin="0,10,30,0" AutoGenerateColumns="False" Style="{DynamicResource DataGridStyle}" HorizontalScrollBarVisibility="Hidden" SelectedItem="{Binding SelectedTask}"> <DataGrid.Columns> <DataGridTextColumn> <DataGridTextColumn.ElementStyle> <Style TargetType="TextBlock"> <Setter Property="Margin" Value="6,0,0,0" /> <Setter Property="Text" Value="{Binding Description}" /> <Setter Property="VerticalAlignment" Value="Center" /> </Style> </DataGridTextColumn.ElementStyle> </DataGridTextColumn> </DataGrid.Columns> </DataGrid>
Edit: I also noticed that when AutoGenerateColumns set to false, and when I insert a new row, the linked text does not get set ... And when I set AutoGeneratedColumns to true, it binds the inserted text.
koala source share