-
Notifications
You must be signed in to change notification settings - Fork 255
MultiSelectComboBox
闫驚鏵(Jinhua Yan) edited this page Apr 16, 2023
·
5 revisions
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Content="获取选中"
VerticalAlignment="Bottom"
HorizontalAlignment="Center"
Click="Button_Click"
Margin="0,20,0,0"
Style="{StaticResource WarningPrimaryButton}"/>
<UniformGrid Columns="2" Rows="2" Grid.Row="1">
<wd:MultiSelectComboBox
VerticalContentAlignment="Center"
IsSelectAllActive="True"
HorizontalAlignment="Center"
Delimiter="^" Width="200">
<wd:MultiSelectComboBoxItem>Option 1</wpfdev:MultiSelectComboBoxItem>
<wd:MultiSelectComboBoxItem>Option 2</wpfdev:MultiSelectComboBoxItem>
<wd:MultiSelectComboBoxItem>Option 3</wpfdev:MultiSelectComboBoxItem>
<wd:MultiSelectComboBoxItem>Option 4</wpfdev:MultiSelectComboBoxItem>
<wd:MultiSelectComboBoxItem>Option 5</wpfdev:MultiSelectComboBoxItem>
</wd:MultiSelectComboBox>
<wd:MultiSelectComboBox Name="MyMultiSelectComboBox"
VerticalContentAlignment="Center"
HorizontalAlignment="Center"
ItemsSource="{Binding Drawings}"
DisplayMemberPath="Number"
SelectedValuePath="Index"
Width="200"
IsSelectAllActive="True"
wd:ElementHelper.Watermark="MultiSelectComboBox">
<wd:MultiSelectComboBox.DataContext>
<vm:DrawingExampleVM/>
</wd:MultiSelectComboBox.DataContext>
</wpfdev:MultiSelectComboBox>
</UniformGrid>
</Grid>
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
WPFDevelopers.Controls.MessageBox.Show($"{MyMultiSelectComboBox.Text} \r\n总共选中:{MyMultiSelectComboBox.SelectedItems.Count} 条", "选中内容", MessageBoxButton.OK, MessageBoxImage.Information);
}