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
1770
Getting selected underlying ID back from XamMultiComboEditor in XamDataGrid
posted

Hello. There is probably a simple answer to this but I can't seem to figure it out. I have a XamMultiComboEditor in a field in a XamDataGrid:

<Style x:Key="DirectivesStyle" TargetType="{x:Type igWPF:XamTextEditor}">
<Setter Property="EditTemplate">
<Setter.Value>
<ControlTemplate>
<ig:XamMultiColumnComboEditor Name="DirectivesMultiComboEditor"
ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}},
Path=DataContext.OpsDirectiveCodes,
Mode=TwoWay}"

DisplayMemberPath="ops_directive"
SelectedValuePath="OpsDirectiveCodesID"
Loaded="XamMultiColumnComboEditor_OnLoaded"

SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=Value, Mode=TwoWay,
Converter={StaticResource DirectivesToStringConverter}}"
Width="285"
/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<igWPF:Field Name="Directive" Width="300">
<igWPF:Field.Settings >
<igWPF:FieldSettings EditorStyle="{StaticResource DirectivesStyle}" />
</igWPF:Field.Settings>
</igWPF:Field>

public class DirectivesToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return "";

return (value as ops_directives_codes).ops_directive;
}
}

I would like to get back the underlying OpsDirectiveCodesID that is associated with whatever they select in the editor but all I keep getting back is the text value. I thought the statement SelectedValuePath="OpsDirectiveCodesID" would do that. What am I missing?

Thanks

Parents
No Data
Reply
  • 16495
    Verified Answer
    Offline posted

    Hello KrisVice,

     

    Thank you for your post.

     

     

    I have been looking into it and the code snippet that you have provided. I created sample application based on your scenario and I could not managed to reproduce the behavior that you have described. If you are not able to reproduce the issue with the attached sample application, would you please modify it with the functionality, that you are using, so it reproduces the issue. This way I would be able to further investigate this for you and provide you with more detailed information on this matter.

     

    Looking forward to hearing from you.

    GetSelectedIdBack.zip
Children
No Data