Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to bind DataTable to DataGridComboBoxColumn
    primarykey
    data
    text
    <p>I have and DataGridComboBoxColumn in the DataGrid a WPF window. I am assigning DataContext to Window as below:</p> <pre><code>cls = new MyClass { selValue = 2, DataGrid = dtGrid, ComboGrid = dtCombo }; this.DataContext = cls; </code></pre> <p>Following is the XAML for DataGridComboBoxColumn:</p> <pre><code> &lt;DataGridComboBoxColumn Header="Item Name" SelectedValueBinding="{Binding Path=Item_Id}" SelectedValuePath="ItemId" DisplayMemberPath="ItemName"&gt; &lt;DataGridComboBoxColumn.ElementStyle&gt; &lt;Style TargetType="ComboBox"&gt; &lt;!-- modified this code as per suggestion ///--&gt; &lt;Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.ComboGrid }" /&gt; &lt;/Style&gt; &lt;/DataGridComboBoxColumn.ElementStyle&gt; &lt;DataGridComboBoxColumn.EditingElementStyle&gt; &lt;Style TargetType="ComboBox"&gt; &lt;Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.ComboGrid }" /&gt; &lt;/Style&gt; &lt;/DataGridComboBoxColu </code></pre> <p>mn.EditingElementStyle> </p> <p>Still Combobox in grid showing blank. No data is being listed in Combobox. Then, I wrote following code in Windows codebehind, it start working.</p> <pre><code>((DataGridComboBoxColumn)this.testGrid.Columns[1]).ItemsSource = cls.ComboGrid.DefaultView; </code></pre> <p><strong>Is there anyway to handle this case in XMAL itself using MVVM? I am reluctant to use this apporache.</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload