我无法从如何获取WPF Toolkit' CheckComboBox
中所有选中项目的列表这样简单的事情。
查看:
<xctk:CheckComboBox DisplayMemberPath="Name"
ItemsSource="{Binding RouteSheetRecordOperations, Mode=OneWay}"
SelectedItemsOverride="{Binding SelectedRouteSheetRecordOperations, Mode=OneWayToSource}" />
查看型号:
Public ReadOnly Property RouteSheetRecordOperations As New ObservableCollection(Of RouteSheetRecordOperation)
Property SelectedRouteSheetRecordOperations As List(Of RouteSheetRecordOperation)
Get
Return _selectedRouteSheetRecordOperations
End Get
Set
_selectedRouteSheetRecordOperations = Value
End Set
End Property
主要问题是在SelectedRouteSheetRecordOperations
属性的setter中,Value始终为Nothing(null)。
答案 0 :(得分:2)
从Mode=OneWayToSource
Binding
<xctk:CheckComboBox DisplayMemberPath="Name"
ItemsSource="{Binding RouteSheetRecordOperations, Mode=OneWay}"
SelectedItemsOverride="{Binding SelectedRouteSheetRecordOperations}" />
另请注意,当您在SelectedRouteSheetRecordOperations
中选择项目时,CheckComboBox
属性的setter不会被命中。应该将一个项目添加到源集合中,这样您也可以删除setter,并且您可能希望返回ObservableCollection(Of RouteSheetRecordOperation)
。
另请注意,该媒体资源必须为public
。
尝试使用上述XAML标记:
Private _selectedRouteSheetRecordOperations As New ObservableCollection(Of RouteSheetRecordOperation)
Public ReadOnly Property SelectedRouteSheetRecordOperations As ObservableCollection(Of RouteSheetRecordOperation)
Get
Return _selectedRouteSheetRecordOperations
End Get
End Property