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 with concatenated displayMemberPath
posted

Hello,

I have the following code -

<igEditors:XamComboEditor ItemsSource="{Binding Instances}"
                                          Margin="5,2,5,2" Width="175" HorizontalAlignment="Left"
                                          SelectedItem="{Binding SelectedInstance,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnDataErrors=True,ValidatesOnExceptions=True}"
                                          >
                    <igEditors:XamComboEditor.ComboBoxStyle>
                        <Style TargetType="ComboBox">
                            <Setter Property="ItemTemplate">
                                <Setter.Value>
                                    <DataTemplate>
                                        <TextBlock>
                                            <TextBlock.Text>
                                                <MultiBinding StringFormat="{}{0} ({1})">
                                                    <Binding Path="Name" />
                                                    <Binding Path="Id" />
                                                </MultiBinding>
                                            </TextBlock.Text>
                                        </TextBlock>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>                        
                    </igEditors:XamComboEditor.ComboBoxStyle>
                </igEditors:XamComboEditor>

When I set the SelectedInstance from my viewmodel, the combobox is displaying the type of the object.  If I then make a selection, it displays correctly, but I click out of the combobox, losing focus, it reverts back to the object type. If I set the DisplayMemberPath manually to just Name, it works correctly, but I really need it to be a concatenated value for the displaymemberpath.

Can anyone help?

Thanks

Parents
  • 138253
    Verified Answer
    Offline posted

    Hello,

     

    Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I used the XamComboEditor’s ValueToDisplayConverter in order to convert the value that will display when not in edit mode. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.

    xamComboEditorDataTemplate.zip
Reply Children