I have a xamComboEditor bound to a DataView in my ViewModel.
The DataView has 3 fields textfield, valuefield, and IsSelected.
I am trying to bind to a property that would indicate that a ComboBoxItem IsSelected.
Using the included combo box with wpf, I would do this with the item container style.
Like this.
<ComboBox Grid.Column="1" ItemsSource="{Binding Values}" DisplayMemberPath="textfield">
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
The end result of this sets which item is selected and updates that dataview as the selection changes.
How do I achieve the same thing using the XamComboEditor?
Hi Gustaf,
You can set the XamComboEditor's ComboBoxStyle property to a Style that targets ComboBox and sets the ItemContainerStyle to the same style you are setting.
Sandip
Hi,
I get binding error with code below. But it works good if I replace binding for IsEnabled with false. Can you please suggest how to bind IsEnabled to the ViewModel property here... thx
: 'EnableComboItem' property not found on 'object' ''String' (HashCode=1746910934)'. BindingExpression:Path=EnableComboItem; DataItem='String' (HashCode=1746910934); target element is 'ComboBoxItem' (Name=''); target property is 'IsEnabled' (type 'Boolean')
<Style x:Key="ComboStyle" TargetType="{x:Type ComboBox}">
<Setter Property="ItemContainerStyle" >
<Setter.Value>
<Setter Property="IsEnabled" Value="{Binding Path=EnableComboItem}" />
</Setter.Value>
</Setter>
<igEditors:XamComboEditor ItemsSource="{Binding Path=SomeList}" ComboBoxStyle="{StaticResource ResourceKey=ComboStyle}"></igEditors:XamComboEditor>