我有一个来自 wpf 工具包 2 的复选框。我无法获得所有选定的项目。我读到我应该使用 SelectedItemsOverride 来获取我选择的所有项目,但它似乎不起作用。我在 TestClassSelected 的设置器中设置了一个断点,但它从未被触发。有任何想法吗?
<xctk:CheckListBox Name="MyCheckList"
ItemsSource="{Binding TestClassCollection}"
DisplayMemberPath="DisplayName"
SelectedItemsOverride="{Binding TestClassSelected}" />
.
public IEnumerable<TestClass> TestClassCollection
{
get { return _testClassCollection; }
set
{
_testClassCollection = value;
OnPropertyChanged("TestClassCollection");
}
}
public List<TestClass> TestClassSelected
{
get { return _testClassSelected; }
set
{
_testClassSelected = value;
OnPropertyChanged("TestClassSelected");
}
}
.
public class TestClass
{
public String FirstName { get; set; }
public String LastName { get; set; }
public String DisplayName {
get { return string.Format("{0} {1}", FirstName, LastName); }
}
}
这是我一直在使用的测试数据。
TestClassCollection = new List<TestClass>
{
new TestClass {FirstName = "FIrstName", LastName = "LastName"},
new TestClass {FirstName = "Brad", LastName = "Holder"},
new TestClass {FirstName = "Sam", LastName = "Ryans"},
new TestClass {FirstName = "Ryan", LastName = "Thomas"},
new TestClass {FirstName = "Lee", LastName = "Rod"},
new TestClass {FirstName = "Amanda", LastName = "Gustaf"},
new TestClass {FirstName = "Chris", LastName = "Holems"},
new TestClass {FirstName = "Doug", LastName = "Schnitzel"},
new TestClass {FirstName = "Lisa", LastName = "Bull"},
new TestClass {FirstName = "Fred", LastName = "Simpson"},
new TestClass {FirstName = "Scott", LastName = "Rogers"}
};