Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions Samples/CheckItem-By-Property/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,14 @@
</local:ViewModel>
</Window.Resources>
<Grid>
<syncfusion:CheckListBox ItemsSource="{Binding VirtualCollection}"
<syncfusion:CheckListBox IsCheckedMemberPath="Enabled"
ItemsSource="{Binding VirtualCollection}"
GroupDescriptions="{Binding GroupDescriptions}"
DataContext="{StaticResource viewModel}"
DisplayMemberPath="Name"
Name="checkListBox"
Margin="20">

<!--Binding the IsChecked property from ViewModel-->
<syncfusion:CheckListBox.Resources>
<Style TargetType="syncfusion:CheckListBoxItem">
<Setter Property="IsChecked" Value="{Binding Mode=TwoWay, Path=IsChecked}"/>
</Style>
</syncfusion:CheckListBox.Resources>

<!--Disable the Virtualization to update the checked item-->
<syncfusion:CheckListBox.ItemsPanel>
<ItemsPanelTemplate>
Expand Down
22 changes: 19 additions & 3 deletions Samples/CheckItem-By-Property/Model/Model.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CheckItem_By_Property
{
//Model.cs
public class GroupItem
public class GroupItem : INotifyPropertyChanged
{
public string Name { get; set; }
public string GroupName { get; set; }
public bool IsChecked { get; set; }
}
private bool enabled;
public bool Enabled
{
get { return enabled; }
set
{
enabled = value;
OnPropertyChanged("Enabled");
}
}

public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
4 changes: 2 additions & 2 deletions Samples/CheckItem-By-Property/ViewModel/ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ViewModel()
GroupDescriptions = new ObservableCollection<GroupDescription>();

VirtualCollection = new ObservableCollection<GroupItem>();
for (int i = 0; i < 1000; i++)
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
Expand All @@ -51,7 +51,7 @@ public ViewModel()
if (i % 2 == 0)
{
//Define a checked state for items
myitem.IsChecked = true;
myitem.Enabled = true;
}
VirtualCollection.Add(myitem);
}
Expand Down