I have a XamDataGrid with a XamComboEditor set as one of the fields, the item-source for this field is a list of objects with a enum as the id and a string as the name.
When the XamDataGrid is gruoped by this field it displays the id as the fieldname instead of the name.
What's really weird is that if I reload the item-source the name is displayed correctly.
<igDP:ComboBoxField Name="field" Label="fieldLabel" Width="200" DisplayMemberPath="Name" ValuePath="Id" DropDownButtonDisplayMode="OnlyInEditMode"> <igDP:ComboBoxField.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}" BasedOn="{StaticResource XamComboEditorStyle}"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.SelectableValues, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" /> </Style> </igDP:ComboBoxField.EditorStyle> </igDP:ComboBoxField>
public List<SelectableValuesViewModel> SelectableValues { get; set; } public class SelectableValuesViewModel { public EnumType Id { get; set; } public string Name { get; set; } public SelectableValuesViewModel(EnumType id, string name) { this.Id = id; this.Name = name; } }
Hi Alexander,
Thank you for clarifying.
I am able to reproduce this and have reached out to the development team in an effort to investigate whether this behavior might be an issue in the XamDataGrid, or rather in the RelativeSource binding.
According to them, such behaviors might indeed occur in relation to the RelativeSource binding since it will be asynchronous.
Having this in mind, my suggestion is to use the FieldBinding, as shown in the original sample I shared instead.
If I can assist you with anything else on the matter, please, let me know.
Best regards,
Bozhidara Pachilova
Hi,
i was able to reproduce the behavor in the attached sample.In order for the behavor to occur the data needs to be grouped by the enum field and then by a string field. I also noticed that this only hapens when the item-source is set from a RelativeSource FindAncestor.
Best regards,Alexander Markelov
8831.XDGComboBoxField.zip
I have been looking into your question and created a small sample with a XamDataGrid containing a ComboBoxField bound to similar data as the one you have shared. In addition, the bound data consists of simple objects having an integer and such an “EnumType” fields. So, the ComboBoxField is bound to the EnumType value, as I assume from the provided code-snippet, having in mind that he ValuePath is set to “Id”. Since the”Name” string is configured as DisplayMemberPath, this is what is expected to be shown as the ComboBoxField’s values and on my side I am not observing the described behavior:
For your convenience, I am attaching the sample I am testing with. Please, check it out on your side as well and do compare the discrepancies between it and your app that may lead to the reported behavior. Alternatively, if you are able to reproduce it in the sample, please share the steps you are performing, so we can investigate it on our side.
Best regards,Bozhidara PachilovaAssociate Software Developer
5554.XDGComboBoxField.zip