I've got a problem with the WPF DataGrid
which I can't really explain/solve.
When I want to type in some values into a cell, I'm only "allowed" to type exactly one character, then the DataGrid
cell loses focus and the whole row is selected.
I can "solve" this problem when I remove the databinding from the DataGridTextColumn
from code below.
<DataGrid x:Name="dataGrid1" ItemsSource="{Binding Items,UpdateSourceTrigger=PropertyChanged,Mode=OneWay}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CanUserAddRows="True" CanUserDeleteRows="True" AutoGenerateColumns="False" Height="auto" Width="auto" Margin="2,0,0,0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<cmd:EventToCommand Command="{Binding SelectionChangedCommand,Mode=OneWay}" CommandParameter="{Binding SelectedItems}">
</cmd:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers>
<DataGrid.Columns>
<DataGridTextColumn Header="SampleHeader" Binding="{Binding Path=SampleText, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Width="auto"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>