Command binding and double CheckBox

Hi,

I use MVVM and command binding to click event. The problem is I have double checkbox displayed and cound find solution to get rid off it and keep command binding.

double checkbox.png


<syncfusion:CheckListBox
ItemsSource="{Binding UpsOptionsCollection, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
SelectedItems="{Binding CheckedOptions, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">

<syncfusion:CheckListBox.Resources>
<Style TargetType="syncfusion:CheckListBoxItem">
<Setter Property="IsChecked" Value="{Binding IsChecked, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" />
</Style>
</syncfusion:CheckListBox.Resources>

<syncfusion:CheckListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="250" />
</ItemsPanelTemplate>
</syncfusion:CheckListBox.ItemsPanel>
<syncfusion:CheckListBox.ItemTemplate>
<DataTemplate>
<Border>
<StackPanel>
<CheckBox Content="{Binding Name}"
IsChecked="{Binding IsChecked, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding DataContext.GetUpsOptionsCommand, RelativeSource={RelativeSource AncestorType=syncfusion:CheckListBox}}" CommandParameter="{Binding}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</CheckBox>
</StackPanel>
</Border>
</DataTemplate>
</syncfusion:CheckListBox.ItemTemplate>
</syncfusion:CheckListBox>

Br,

Jakub


1 Reply

SS Sekar Sivalingam Syncfusion Team November 13, 2024 04:27 PM UTC

Hi Jakub Olichwier,

We have prepared a sample project that fully meets your requirement for using ICommand with the click event in Syncfusion's CheckListBox while adhering to the MVVM pattern. The sample resolves the issue of double checkboxes and successfully binds the click event using ICommand.

Please find the attached sample for your reference. Kindly review it and let us know if this resolves your issue or if you need any further assistance.

Thank you for your patience, and we look forward to your feedback.

Regards,

Sekar Sivalingam


Attachment: WpfApp1_23217315.zip

Loader.
Up arrow icon