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.
Last question:
How can i bind the itemssource without setting it programmatically in the code behind. If bind in ResolveDisplayElement, the list is filled but the binding to the selected item doesn't work.
It works now! Thank you! The problem was, that i created my own binding and didn't used the original cellBinding.
Sorry, i left out one thing, you'd need to make the CellBinding.Mode = twoWay:
cellBinding.Mode = BindingMode.TwoWay;
I've also attached the modified sample:
-SteveZ
Thanks for your reply, i changed everything but it still doesn't work.
Thanks for the sample.
So there are a few reasons why you're seeing strange behavior.
1. You don't have a property that stores the SelectedItem for your data. So in this example, your Car class needs to have a SelectedEquipment property, and thats the property that the ComboBoxColumn should be used fore:
public class Car
{
public string Name { get; set; }
public Equipment SelectedEquipment { get; set; }
public ObservableCollection<Equipment> Equip { get; set; }
}
<igcc:ComboBoxColumn Key="SelectedEquipment" DisplayMemberPath="SeatName" Width="200" IsReadOnly="True" />
2. In the ResolveDisplayElement you're setting the Source of the selectedItemBinding to be the row's data. When you shouldn't set the the source, b/c that element will be recycled, and the data will be stuck, which is why you're seeing the alternating values when you collapse and expand. And actually, you shouldn't be creating your own binding at all, and should be using the passed in binding of the method:
this._combobox.SetBinding(ComboBox.SelectedItemProperty, cellBinding);
3. Finally, you're ignoring the ItemsSource property on the column and creating your won in ResolveDisplayElement. What this means, is that every time the the element is recycled, it will resolve the SelectedEquipment property as null, b/c the Equipment that is selected will actually be a different object than the ItemsSource being used. So, you need to ditch the following code, and use the ItemsSOurce off of the column:
// Get Rid of this:
List<ComboBoxColumnDemo.Equipment> equipments = new List<ComboBoxColumnDemo.Equipment>();
Random c = new Random();
equipments.Add(new ComboBoxColumnDemo.Equipment() { SeatName = "LighteningSeat" + (c.Next() % 10), WheelName = "LighteningWheel" });
equipments.Add(new ComboBoxColumnDemo.Equipment() { SeatName = "LighteningSeat" + (c.Next() % 10), WheelName = "LighteningWheel2" });
equipments.Add(new ComboBoxColumnDemo.Equipment() { SeatName = "DocSeat" + (c.Next() % 10), WheelName = "DocWheel" });
equipments.Add(new ComboBoxColumnDemo.Equipment() { SeatName = "DocSeat" + (c.Next() % 10), WheelName = "DocWheel2" });
this._combobox.SetValue(ComboBox.ItemsSourceProperty, equipments);
// Use this:
this._combobox.SetValue(ComboBox.ItemsSourceProperty, column.ItemsSource);