How to Access cell’s control of the row in Datagrid

Topics: Prism v2 - WPF 3.5, Prism v2 - WPF 4, Prism v4 - WPF 4
Jul 27, 2010 at 10:57 AM

I am using the WPF datagrid, I have added the columns DataGridComboBoxColumn, DataGridTemplateColumn programatically.

I want every row (every comboBox) of the the column with the different datasource may be first row’s ComboBox will have 5 items and second row’s ComboBox will have 3 items.



------------added blank StackPanel ---------------


       <DataTemplate x:Key="manageAreaCellTemplate">

           <StackPanel Orientation="Horizontal">              




--------------Added Column ------------

DataGridTemplateColumn dgTemplateColumn = new DataGridTemplateColumn();

dgTemplateColumn.Width = new DataGridLength(1, DataGridLengthUnitType.Star);

dgTemplateColumn.Header = "Manage Options";

dgTemplateColumn.CellTemplate = this.FindResource("manageAreaCellTemplate") as                                                                                    DataTemplate;          



-------------- dataGrid1_LoadingRow Event------------





void dataGrid1_LoadingRow(object sender, Microsoft.Windows.Controls.DataGridRowEventArgs e)





           DataTemplate dt = (DataTemplate)e.Row.FindResource("manageAreaCellTemplate");

           object stk = dt.LoadContent();

           StackPanel stk1 = new StackPanel();

           stk1 = (StackPanel)stk;

           ComboBox cmb = new ComboBox();

           PortInfoCollection portInfoCollection = new PortInfoCollection();

           cmb.ItemsSource = portInfoCollection;

           cmb.SelectedValuePath = "Visits";

           cmb.DisplayMemberPath = "Port";






My problem is combobox is not getting populated in the grid

Oct 4, 2010 at 9:44 PM


There is no guidance on this topic in Prism out-of-the-box. But you can find interesting the following blog post where there is an approach that solves a similar scenario:

As this questions is not related to Prism, you could also use the WPF official forum if you have more questions about WPF.

Fernando Antivero