Hello - We are evaluating your product and have a question regarding binding converters.
We have a ComboBox in our XamDataGrid. It's ItemSource is an observable collection of id/value pairs. The selected value of the ComboBox is bound to a property in our view model. Everything works fine if the bound property is a native string. However, if we attempt to bind to a property of a complex type using a converter, the value coming into the converter is always null.
Here is the XAML (ItemsSource is bound in code behind):
<igDP:ComboBoxField Name="CustomerId" Converter="{StaticResource idToStringConverter}" IsEditable="True" IsEnabled="True"> <igDP:ComboBoxField.EditorStyle> <Style TargetType="igEditors:XamComboEditor"> <Setter Property="ValuePath" Value="Id" /> <Setter Property="DisplayMemberPath" Value="DisplayName" /> </Style> </igDP:ComboBoxField.EditorStyle></igDP:ComboBoxField>
Here is our Converter:
public class IdToStringConverter : IValueConverter { public object Convert ( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { return ( value is Id) ? ( ( Id ) value ).Value: null; } public object ConvertBack ( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { return ( value is string ) ? new Id( value as string ): null; } }
Here is the property we are trying to bind to in our ViewModel:public Id CustomerId { set; get; }
When we bind to a native WPF DataGrid ComboboxColumn, it is simply this:
<DataGridComboBoxColumn SelectedValueBinding="{Binding Path=CustomerId, Converter={StaticResource idToStringConverter}}" SelectedValuePath="Id" DisplayMemberPath="DisplayName"/>
We have searched your forums and samples but have not found a straightforward answer.
Thank you
Hello Jeannie,
Thank you for following up. Please attach the sample here. I did not receive any attachments on your private case. Please note that I'd like to continue our discussion here so the community can see a resolution. If a private case is necessary then I can transition this forum post without the need of creating another case. Once I have your new sample, may I close your private case since we won't be using it?
Hello Michael,
We have a license now, so I've submitted the issue under Priority Support Case# CAS-189923-J9N6W1 with a sample project.
Thank youJeannine
Hello Jeannine,
I attached a new sample, nothing fancy but demonstrates that the Converter property on the ComboBoxField is working correctly. I simply changed a enum value based on the selection. Please modify it to demonstrate the issue if needed.
7384.WpfApplication1.zip
Let me know if you have any questions.
Hi Michael - Thank you for researching. Raytheon is shutdown until the New Year, but we are still very much interested in a resolution.
I do want to say that we are impressed with the robustness of your products and with the responsiveness and professionalism of your technical and sales support staffs. You should all be very proud.
We look forward to working with you in the New Year.
Happy Holidays
Jeannine
I am currently in the middle of writing a sample to isolate this behavior and determine if it's a development issue or not. Please note we are closed Monday and Tuesday for the holidays. Let me know if you have any questions.