I use the following XAML to display a XamComboEditor-field in my XamDataGrid
<igDP:Field Name="NoteType" Label="Type" Width="70">
<igDP:Field.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="ItemsSource" Value="{Binding NoteTypes}" />
<Setter Property="DisplayMemberPath" Value="Name" />
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
Name="NoteType" refers to the key in the table/collection that contains the name that should be displayed
The column is displayed in the DataGrid, but the Name of the NoteType isn't displayd, only the key.
Am I missing something here?
Maybee this will help you:
<Style x:Key="TypeFieldStyle" TargetType="{x:Type igEditors:XamComboEditor}" BasedOn="{StaticResource ResourceKey=XamComboEditorDropDownButtonDisplayStyle}">
<Style.Setters>
<Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.AtmTypesList}" />
<Setter Property="SelectedItem" Value="{Binding Path=DataItem.Type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="ValuePath" Value="Id" />
<Setter Property="IsEditable" Value="True" />
</Style.Setters>
In XamDataGrid:
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:UnboundField BindingPath="CaseTypeId" Label="Тип кассет">
<igDP:UnboundField.Settings>
<igDP:FieldSettings EditorStyle="{StaticResource CaseTypeFieldStyle}" />
</igDP:UnboundField.Settings>
</igDP:UnboundField>
<igDP:Field Name="Count" Width="*" Label="Количество"/>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
in my binded DTO class
[DataContract]
public class AtmModelConfiguration : GuidDto<AtmModelConfiguration>
{
public Guid? CaseTypeId
get { return CaseType == null ? (Guid?)null : CaseType.Id; }
set
if (value.HasValue)
CaseType = new IdNamePair<Guid> { Id = value.Value };
}
private IdNamePair<Guid> _caseType;
[DataMember]
public IdNamePair<Guid> CaseType
get { return _caseType; }
_caseType = value;
RaisePropertyChangedEvent(() => CaseType);
public uint Count { get; set; }
where IdNamePair<Guid> is class with fields Guid Id and Name
Name - Displays Id - value
Hello again Matt
I actually have another question to this issue.
Although the above solution works just fine with the "Note-example", I would like to know if it is possible to databind the Combobox using SelectedItem instead of ValuePath?
In some cases this would be nice in order to update my ViewModel/database...
Hello Matt
I have looked at the sample and used it in my project. It now works just fine!
HI,
I am attaching a new sample that binds the XamComboEdtior's ItemSource to the DataContent.
Plesase review my sample.
Sincerely,
Matt Developer Support Engineer
Please help, spent a second day on this issue, read the entire forum and the internet, and nothing found it.