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?
HI,
I am attaching a sample application that embeds a XamComboEdtior into the XamDataGrid.
Sincerely, Matt Developer Support Engineer
I am just following upu on this forum post.
Please let me know if you need further assistance regarding this issue.
Sincerely,Matt Developer Support Engineer
It is also faced with similar problems ...The dropdown list shows a list of items, but when I select an item from the drop-down list, it is not updated in the field, and when I triggered the event DataGridRecordUpdating (object sender, RecordUpdatingEventArgs e)
var item = e.Record.DataItem;
var res = DoUpdate(ref item);
but the item.Manufacturer = null
The result is that I can not save changes to the database
My DataGrid xaml
<igDP:XamDataGrid HorizontalAlignment="Stretch" Name="xamDataGridAtmModels" VerticalAlignment="Stretch" Grid.Row="1" GroupByAreaLocation="None"
ActiveDataItem="{Binding Path=SelectedAtmModel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AutoGenerateFields="False"
AllowAddNew="True"
AddNewRecordLocation="OnBottom" />
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings CellClickAction="SelectRecord"></igDP:FieldSettings>
</igDP:XamDataGrid.FieldSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:UnboundField BindingPath="Manufacturer" BindingMode="TwoWay" Label="Производитель">
<igDP:UnboundField.Settings>
<Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.ManufacturersList}" />
<Setter Property="ValuePath" Value="Id"/>
</igDP:UnboundField.Settings>
</igDP:UnboundField>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
as the DataSource I Use my ServerModeDataSource
<eid:ServerModeDataSource Name="AtmModelsDataSource"
EntityType="{Binding Path=EntityType, Mode=OneWay}"
DataGrid="{Binding ElementName=xamDataGridAtmModels, Path=.}"
SelectMethod="{Binding Path=SelectMethod, Mode=OneWay}"
UpdateMethod="{Binding Path=UpdateMethod, Mode=OneWay}"
DeleteMethod="{Binding Path=DeleteMethod, Mode=OneWay}"/>
In ViewModel:
public BindingList<IdNamePair<Guid>> ManufacturersList
public AtmModel SelectedAtmModel
{
get { return _selectedAtmModel; }
set
_selectedAtmModel = value;
RaisePropertyChangedEvent(() => SelectedAtmModel);
}
public class IdNamePair<T> : ValidatableUiFriendlyObject, IDataTransferObject
private T _id;
/// <summary>
/// Entity Id.
/// </summary>
[DataMember]
public T Id
get { return _id; }
_id = value;
RaisePropertyChangedEvent(() => Id);
internal Guid? VirtualId;
private string _name;
/// Entity name.
public virtual string Name
get { return _name; }
_name = value;
RaisePropertyChangedEvent(() => Name);
Please Help with this problem....
Please help, spent a second day on this issue, read the entire forum and the internet, and nothing found it.
I am attaching a new sample that binds the XamComboEdtior's ItemSource to the DataContent.
Plesase review my sample.
Sincerely,
Matt Developer Support Engineer
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...
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:UnboundField BindingPath="CaseTypeId" Label="Тип кассет">
<igDP:FieldSettings EditorStyle="{StaticResource CaseTypeFieldStyle}" />
<igDP:Field Name="Count" Width="*" Label="Количество"/>
in my binded DTO class
[DataContract]
public class AtmModelConfiguration : GuidDto<AtmModelConfiguration>
public Guid? CaseTypeId
get { return CaseType == null ? (Guid?)null : CaseType.Id; }
if (value.HasValue)
CaseType = new IdNamePair<Guid> { Id = value.Value };
private IdNamePair<Guid> _caseType;
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 Matt
I haven't really had the time to look into this issue again...
I think, I might try experimenting with the standard WPF-DataGrid again, to get the desired functionality with SelectedItem-binding.
Thanks for the help!
I am just following up on this forum post.
HI Christian,
As for binding using the XamComboSelectedItem, you probably could, you would need a converter.
But using the ValuePath propety is much easier and more efficient.
Nope. The binding doesn't work in my case...