Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
160
XamComboEditor setting selected Item
posted

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?

Parents
  • 160
    posted

    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????

Reply Children