I am hoping someone can help me out with this. I have asked a similar question before but I didn\'t have anything started on this at the time. I have found the SO question l
If you need to show a "concatenation" of the selected items (i.e. if I check SAW and SMAW enum values, I would like to see in the ComboBox Text something like "SAW, SMAW"), you can take a look to this Multi Select ComboBox in WPF.
You will find both a MVVM version and "codebehind" one.
EDIT
Ok, you can go the CodeProject and download the MultiSelectComboBox dll. Add it in your project. Then in your XAML you can add:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:multi="clr-namespace:MultiSelectComboBox;assembly=MultiSelectComboBox"
Title="MainWindow" Height="350" Width="600">
<!-- your xaml -->
<multi:MultiSelectComboBox Margin="4" Name="MultiSelectComboBox" />
<!-- the rest of your xaml -->
</Window>
Then in your code-behind (I used for my sample the TextAlignment
enum):
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Dictionary<string, object> itemsSource = new Dictionary<string, object>();
itemsSource.Add(Convert.ToString(TextAlignment.Center), TextAlignment.Center);
itemsSource.Add(Convert.ToString(TextAlignment.Justify), TextAlignment.Justify);
itemsSource.Add(Convert.ToString(TextAlignment.Left), TextAlignment.Left);
itemsSource.Add(Convert.ToString(TextAlignment.Right), TextAlignment.Right);
MultiSelectComboBox.ItemsSource = itemsSource;
}
}
The SelectedItems
property of the MultiSelectComboBox will contain the values that the user selected.
Is it what you needed?
If you are using MVVM you can expose the ItemsSource and the SelectedItems dictionaries with your ViewModel.