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?
Hello,
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
Thank you for your post. I have been looking into it, but it seems like I am missing something about your scenario, so could you please provide me with an isolated sample, where this issue is reproduced so I can investigate this further for you.
Looking forward for your reply.
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.
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.