I've a problem with my selected items recuperation in my datagrid.
In my xaml file, I've this :
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SelectionChanged}" CommandParameter="{Binding SelectedItems, ElementName=technicalAlarmDatagrid}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
Then, in my ViewModel, I've the binding Command like this :
public ICommand SelectionChanged
{
get
{
if (_selectionChangedCommand == null)
_selectionChangedCommand = CreateCommand<object>(OnSelectionChanged);
return _selectionChangedCommand;
}
}
private void OnSelectionChanged(object parameter)
{
...
}
Now, my problem is : In my datagrid, if I just have one item, the selectionChanged event doesn't work. But if I have more than one item, so, my event works.
Do you have any idea in order to solve my problem ? Thank a lot !
In your XAML Code add attribute SelectedIndex="-1"
<DataGrid SelectedIndex="-1" SelectionChanged="DataGridSelectionChanged" ...>
...
</DataGrid>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.