I am binding a dictionary (int, string) to a xamcombobox as follows
<igDP:UnboundField Width="70" ToolTip="Assigned Entity" Tag="EntityString" Label="Assigned Entity" BindingPath="EntityString" BindingMode="TwoWay"> <igDP:UnboundField.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource LegalEntityDropdownCellStyle}" EditorType="{x:Type igEditors:XamComboEditor}"/> </igDP:UnboundField.Settings> </igDP:UnboundField>
where the CellValuePresenterStyle is defined as
<Style x:Key="LegalEntityDropdownCellStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <igEditors:XamComboEditor SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Mode=TwoWay}" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}, Path=DataContext.LegalEntityNames}" DisplayMemberPath="Value" ValuePath="Key"/> </ControlTemplate> </Setter.Value> </Setter> </Style>
I find that the value of the items in the combobox is in format "[key, value]" so I bind the field to a similarly formatted string. At the moment, the selectedItem in the combo box is not set. Any idea how to achieve that?
Iam able to set the selected item in the XamComboEditor but have another problem now...
Basically I have 2 ObservableCollections (say A1 and A2). public class A1{ public virtual int Individual_ID { get; set; } public virtual string Tel_Number { get; set; } public virtual string Tel_Code { get; set; } public virtual string Dial_Number { get; set; } public virtual string Extension { get; set; }}public class A2{ public virtual string Tel_Code { get; set; } //ValuePath public virtual string Tel_Desc { get; set; } //DisplayMemberPath}A1 is bound to the XamDataGrid and A2 is bound to the XamComboEditor. The XamDataGrid & XamComboEditor are populated fine with their respective datasources.Now, when i select another item from the XamComboEditor, the value is not getting updated in the ObservableCollection A1. When i check for the same in the ObservableCollection A2 the first item of the XamComboEditor is being set as the value.
Requirement: We are using EF and I need to save A1 to database. Please help.
Thanks a ton Stefan. Its working now.
Really appreciate your help.
Hello,
I have created a sample project for you following your scenario and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.
I have the same issue and I am not able to set "SelectedItem" of a XamComboEditor inside a XamDataGrid.
Please help.
Well it only works if I make the combobox the second column in the grid. If it is the first column then the AddNew record doesn't work as expected.