I am binding a dictionary (int, string) to a xamcombobox as follows
<igDP:UnboundField Width="70" ToolTip="Assigned Entity" Tag="EntityString" Label="Assigned Entity" BindingPath="EntityString" BindingMode="TwoWay"> <igDP:UnboundField.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource LegalEntityDropdownCellStyle}" EditorType="{x:Type igEditors:XamComboEditor}"/> </igDP:UnboundField.Settings> </igDP:UnboundField>
where the CellValuePresenterStyle is defined as
<Style x:Key="LegalEntityDropdownCellStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <igEditors:XamComboEditor SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Mode=TwoWay}" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=DataContext.LegalEntityNames}" DisplayMemberPath="Value" ValuePath="Key"/> </ControlTemplate> </Setter.Value> </Setter> </Style>
I find that the value of the items in the combobox is in format "[key, value]" so I bind the field to a similarly formatted string. At the moment, the selectedItem in the combo box is not set. Any idea how to achieve that?
Changed BindingPath="EntityString"
EntityString to be a KeyValuePair and the selected item sets correctly. However if I change the selected item it gives me a conversion error. Added a converter to convert the "[key,value]" string to an actual KeyValue pair but no luck.
Anyone????
Added converter to field
<igDP:UnboundField Width="70" ToolTip="Assigned Entity" Tag="EntityString" Label="Assigned Entity" BindingPath="EntityString" Converter="{StaticResource legalEntityNameConverter}" BindingMode="TwoWay">
<igDP:UnboundField.Settings>
<igDP:FieldSettings AllowEdit="True" CellValuePresenterStyle="{StaticResource LegalEntityDropdownCellStyle}" EditorType="{x:Type igEditors:XamComboEditor}" />
Still getting the conversion error on selecting the a new value. Apparently the converter kicks in after the value is bound to the underlying field.