Improve CheckComboBox example

This commit is contained in:
2023-05-19 00:52:41 +02:00
parent d2c0884b44
commit 2ee7e90bcc
2 changed files with 13 additions and 5 deletions

View File

@ -7,10 +7,10 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
Title="Test Fenster - Elwig" MinHeight="400" MinWidth="325" Height="450" Width="800" ResizeMode="CanResize">
<Grid>
<xctk:CheckComboBox x:Name="_combo" Width="200"
HorizontalAlignment="Center"
VerticalAlignment="Center"
<xctk:CheckComboBox x:Name="MyComboBox" HorizontalAlignment="Left" Margin="216,186,0,0" VerticalAlignment="Top" Delimiter=", "
SelectedValue="{Binding SelectedValue}"
SelectedItemsOverride="{Binding SelectedItems}"/>
SelectedItemsOverride="{Binding SelectedItems}"
ItemSelectionChanged="OnItemSelectionChanged"/>
<TextBlock x:Name="MyText" HorizontalAlignment="Left" Margin="318,246,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
</Grid>
</Window>

View File

@ -1,10 +1,18 @@
using System.Collections.Generic;
using System.Windows;
using Xceed.Wpf.Toolkit.Primitives;
namespace Elwig.Windows {
public partial class TestWindow : Window {
public TestWindow() {
InitializeComponent();
_combo.ItemsSource = new string[] { "Klasse A", "Klasse B", "Klasse C", "Klasse D", "Klasse E", "Klasse F" };
MyComboBox.ItemsSource = new string[] { "Klasse A" , "Klasse B", "Klasse C", "Klasse D", "Klasse E", "Klasse F" };
}
private void OnItemSelectionChanged(object sender, ItemSelectionChangedEventArgs e) {
var selected = new List<string>();
foreach (var item in MyComboBox.SelectedItems) selected.Add((string)item);
MyText.Text = string.Join(", ", selected);
}
}
}