Hello @Boris Kleynbok
Welcome to Microsoft Q&A!
I see that your SaveSelectedItemsCommand
is passed the parameter UserRoles.SelectedItems
.
So, just need to create a new variable in the ViewModel to point to SelectedItems
and execute Clear()
when the selection needs to be cleared.
The following code implements the selection three times, then clears all selections.
XMAL:
<ic:EventTriggerBehavior EventName="SelectionChanged">
<ic:InvokeCommandAction
Command="{x:Bind MainViewModel.ClearCommand,Mode=OneWay}"
CommandParameter="{x:Bind UserRoles.SelectedItems,Mode=OneWay}"/>
</ic:EventTriggerBehavior>
ViewModel:
private RelayCommand<object> _clearCommand;
public RelayCommand<object> ClearCommand
{
get
{
_clearCommand = new RelayCommand<object>((s) =>
{
var temp = s as IList<object>;
if (temp.Count >= 3)
{
temp.Clear();
}
});
return _clearCommand;
}
set
{
_clearCommand = value;
}
}
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.