我正在尝试使用Xceed CheckComboBox,它运行良好,除了一个小问题。最初加载 CheckComboBox 时,所选项目列表正确显示在 CheckComboBox 的 ToggleButton 部分,但表示这些项目的复选框未选中。这是我正在使用的代码
XAML
<xctk:CheckComboBox x:Name="_combo" Grid.Row="2" Grid.Column="1"
ItemsSource="{Binding RoomFacilities}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
DisplayMemberPath="FacilityName"
SelectedItemsOverride="{Binding SelectedFaclities}"
/>
查看模型
public class RoomBandUpdateViewModel : Screen, IHandle<RecordChanged<RoomFacility>>,
IHandle<RecordDeleted<RoomFacility>> {
private ObservableCollection<RoomFacility> _roomFacilities;
public ObservableCollection<RoomFacility> RoomFacilities {
get { return _roomFacilities; }
set { _roomFacilities = value; NotifyOfPropertyChange(() => RoomFacilities); }
}
private ObservableCollection<RoomFacility> _selectedFacilities;
public ObservableCollection<RoomFacility> SelectedFaclities {
get { return _selectedFacilities; }
set { _selectedFacilities = value; NotifyOfPropertyChange(() => SelectedFaclities); }
}
protected override void OnActivate() {
SelectedFaclities = new ObservableCollection<RoomFacility>(RoomBand.Facilities);
RoomFacilities = new ObservableCollection<RoomFacility>(facilityService.GetAll());
}
}
我想知道为什么在视图模型中正确设置SelectedFacilities时,不会根据SelectedFacilities中的项目检查 CheckComboBox 的复选框。有趣的部分是 CheckComboBox 的 Toggle Button 部分在逗号分隔列表中正确显示SelectedFacilities 。