8,735
社区成员
发帖
与我相关
我的任务
分享
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register("ItemsSource", typeof(ObservableCollection<MultiComboBoxModel>), typeof(MulitComboBoxUserControl),new UIPropertyMetadata(null));
public ObservableCollection<MultiComboBoxModel> ItemsSource
{
get { return (ObservableCollection<MultiComboBoxModel>)GetValue(ItemsSourceProperty); }
set
{
SetValue(ItemsSourceProperty, value);
}
}
public static readonly DependencyProperty SelectedItemsProperty = DependencyProperty.Register("SelectedItems", typeof(ObservableCollection<MultiComboBoxModel>), typeof(MulitComboBoxUserControl), new PropertyMetadata(null,null));
public ObservableCollection<MultiComboBoxModel> SelectedItems
{
get { return (ObservableCollection<MultiComboBoxModel>)GetValue(SelectedItemsProperty); }
set
{
SetValue(SelectedItemsProperty, value);
}
}
<Grid>
<ComboBox Text="{Binding SelectedText}" IsEditable="True" ItemsSource="{Binding ItemsSource}" >
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsChecked}" Click="CheckBox_Click"/>
<TextBlock Text="{Binding Title}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<control:MulitComboBoxUserControl Grid.Row="0" ItemsSource="{Binding ItemsSource}" SelectedItems="{Binding SelectedItems}"></control:MulitComboBoxUserControl>