Search results
I have a converter available able to convert a item of type T to string and vice versa. View My ComboBox bound to the collection and the selected item properties:
I have a ComboBox that is bound to an EnumerableRowCollection<T> : My xaml lookes like this: Text="{Binding FamilyStatus, Converter={StaticResource FamilyStatusStringConverter}}">. I'm using the DisplayMemberPath to show the description of the row.
19 gru 2023 · I have a ComboBox in my custom Control, and I want to bind its "Text" and "Converter" properties to their dependency properties correctly so that I can reuse the custom Control. In some instances, I want to use ComboBoxItems as the source.
Create a converter by implementing the IValueConverter interface and implementing the Convert method. That method should return an object that is of the same type as the dependency property that the binding targets, or at least a type that can be implicitly coerced or converted to the target type.
As you can see from the first examples, manually defining the items of a ComboBox control is easy using XAML, but you will likely soon run into a situation where you need the items to come from some kind of data source, like a database or just an in-memory list.
8 lut 2021 · I'm using a ComboBox with custom item template. CombBox ItemsSource is binded to DistinctThicknessList which is a list of thickness in millimeters. I apply some converters to the ComboBox value and to the ComboBox possible values to show them in inches.
The following example shows how to implement the IValueConverter interface and use the converter when data binding to a collection of objects.