Dee J. Doena Dee J. Doena - 1 year ago 113
C# Question

MVVM: Force ComboBox labels to refresh

I have a ComboBox bound to an


The problem is that
does not support
nor should it.

While the number of elements in my ComboBox is fixed and does not change, the labels shown in the ComboBox can and will change.

How do I get these labels to update?

on my ObservableCollection does not refresh the content of the labels but it does reset the
which is a side-effect I don't even want.

Here's my current XAML:

<ComboBox Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="4"
ItemsSource="{Binding Drives}" SelectedItem="{Binding SelectedDrive}"
IsSynchronizedWithCurrentItem="True" DisplayMemberPath="Label"
Margin="5,5,5,5" VerticalAlignment="Center" />

being the property in my

Answer Source

You will need to wrap the items in a DriveViewModel : INotifyPropertyChanged and have that repeat the relevant properties. And somehow trigger the changed event from that.

On second thought, I'm not sure if DisplayMemberPath picks up on this. You'll probably need an ItemTemplate as well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download