Reputation: 2497
I want to bind a boolean values, list of objects and enum values to a combobox. Depending on the column of a datagrid pops a dialog and I load a list of objects (Object1.Name....ObjectN.Name are Names and ObjectId1..ObjectIdN are Id's), I load a list of EnumValue (EnumItem1..EnumItemN are Names, EnumValue1 .. EnumValueN are Id's), or boolean (Yes/No are Names, and 0/1 the Id's).
How can I do it? Do I need to implement a wrap class in my ViewModel for my combobox? (this wrap class would get list of objects, list yes/no for booleans, list of enumvalues).
Upvotes: 2
Views: 459
Reputation: 157
<Style Target={x:Type ComboBox}>
<Style.Triggers>
<DataTrigger Binding="{Path=RowData.Row.PropertyToBeChecked}" Value="Value1">
<Setter Property="DataSource" Value="{Binding Path=ListCorrespondingToValue1}"/>
</DataTrigger>
<DataTrigger Binding="{Path=RowData.Row.PropertyToBeChecked}" Value="Value2">
<Setter Property="DataSource" Value="{Binding Path=ListCorrespondingToValue2}"/>
</DataTrigger>
</Style.Triggers>
</Style>
Upvotes: 2
Reputation: 157
well, for me i think you can achieve your goal with a trigger in which you set the dataSource of your combo box. it will look like
<Style Target={x:Type ComboBox}>
Upvotes: 1