This is Urgent. Pls help. Changing to cellbinding didn't work. Please help. Here is the code -
DataGridCollectionView
theView = new DataGridCollectionView(roomsListNew, typeof(ExchangeRoomResource), false, false);
theView.DetailDescriptions.Add(
new ParentDetailDescription());
List<ExchangeRoomConflictData> roomsConflictList = new List<ExchangeRoomConflictData>();
roomsConflictList.Add(
new ExchangeRoomConflictData(DateTime.Today.AddMonths(1), "Dynamic Data: Room 1"));
roomsConflictList.Add(
new ExchangeRoomConflictData(DateTime.Today.AddMonths(2), "Dynamic Data: Room 2"));
roomsConflictList.Add(
new ExchangeRoomConflictData(DateTime.Today.AddMonths(3), "Dynamic Data: Room 3"));
Binding binding = new Binding();
binding.Source = roomsConflictList;
DataTemplate myEditorTemplate = new DataTemplate();
myEditorTemplate.VisualTree =
new FrameworkElementFactory(typeof(ComboBox));
myEditorTemplate.VisualTree.SetValue(
ComboBox.ItemsSourceProperty, binding);
myEditorTemplate.VisualTree.SetValue(
ComboBox.SelectedValuePathProperty, "AlternateRoomName");
myEditorTemplate.VisualTree.SetValue(
ComboBox.DisplayMemberPathProperty, "AlternateRoomName");
Xceed.Wpf.DataGrid.Markup.
CellEditorBindingExtension cellbinding = new Xceed.Wpf.DataGrid.Markup.CellEditorBindingExtension();
myEditorTemplate.VisualTree.SetBinding(
ComboBox.SelectedValueProperty, (BindingBase)cellbinding.ProvideValue(null));
CellEditor cellEditor = new CellEditor();
cellEditor.EditTemplate = myEditorTemplate;
this.ctlSearchResults.DetailConfigurations["ConflictDetailRelation"].Columns["SuggestedRoomName"].CellEditor = cellEditor;
Binding
cellcontentbinding = new Binding();
cellcontentbinding.Source = roomsConflictList;
cellcontentbinding.Mode = BindingMode.TwoWay;
cellcontentbinding.Path = new PropertyPath("AlternateRoomName");
cellcontentbinding.UpdateSourceTrigger =
UpdateSourceTrigger.PropertyChanged;
DataTemplate myCellContentTemplate = new DataTemplate();
myCellContentTemplate.VisualTree =
new FrameworkElementFactory(typeof(TextBlock));
myCellContentTemplate.VisualTree.SetValue(
TextBlock.TextProperty, cellcontentbinding);
this.ctlSearchResults.DetailConfigurations["ConflictDetailRelation"].Columns["SuggestedRoomName"].CellContentTemplate = myCellContentTemplate;
this.ctlSearchResults.ItemsSource = theView; // ctlSearchResults is Xceed WPF grid control