Hi,
my xamgrid contains some columns and child columns:
<ig:TextColumn /><ig:TextColumn /><ig:ColumnLayout > <ig:ColumnLayout.Columns><ig:TextColumn /> <XamGridColumns:XamComboEditorColumn />
If i collapse and expand the parent row again the content of the XamComboEditorColumn changes. The other columns keep their content, the cells within the XamComboEditorColumn exchange their content as mentioned. AdjustDisplayElement is called twice for each cell.
Please help, thanks.
I just took your last sample, followed your instructions and did this
<igcc:ComboBoxColumn Key="SelectedEquipment" ItemSourceMemberPath="Equip" DisplayMemberPath="SeatName" Width="200" IsReadOnly="True" />
public override FrameworkElement ResolveDisplayElement(Cell cell, System.Windows.Data.Binding cellBinding) { ComboBoxColumn column = (ComboBoxColumn)cell.Column; Binding b = new Binding(); b.Source = cell.Row.Data; b.Path = new PropertyPath(column.ItemSourceMemberPath); this._combobox.SetBinding(ComboBox.ItemsSourceProperty, b); if (column.DisplayMemberPath != null) this._combobox.SetValue(ComboBox.DisplayMemberPathProperty, column.DisplayMemberPath); cellBinding.Mode = BindingMode.TwoWay; this._combobox.SetBinding(ComboBox.SelectedItemProperty, cellBinding); this._combobox.Style = cell.EditorStyleResolved; return this._combobox; }
ComboBoxColumn
/// <summary> /// Identifies the <see cref="ItemSourceMemberPath"/> dependency property. /// </summary> public static readonly DependencyProperty ItemSourceMemberPathProperty = DependencyProperty.Register("ItemSourceMemberPath", typeof(String), typeof(ComboBoxColumn), null); /// <summary> /// Gets or sets a collection used to generate the content of the <see cref="ItemsControl"/> /// </summary> public String ItemSourceMemberPath { get { return (String)this.GetValue(ItemSourceMemberPathProperty); } set { this.SetValue(ItemSourceMemberPathProperty, value); } }
Could you attach your sample?
-SteveZ
I tried it and unfortunately it doesn't work. If i collapse and expand the parent row again the content of the XamComboEditorColumn changes. The selected item appears and disappears the next time.
Ok, so if equipment is going to be different for each row, you'll probably want to add another property to your column.
Lets call it ItemsSourceMemberPath.
Then you'll create a binding to the ComboBox's ItemsSource property and use that as the path:
Binding b = new Binding();
b.Source = cell.Row.Data;
b.Path = new PropertyPath(column.ItemsSourceMemberPath);
this._combobox.SetBinding(ComboBox.ItemsSourceProperty, b);
You'd probably put this code in the ResolveDisplayElement method.
Let me know if this works,
Unfortunately yes.