Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF DataTemplateColumn access DataTemplate and set ItemsSource
    primarykey
    data
    text
    <p>I know its strange what I am doing but I want this to work. I am going wrong somehwere I feel.</p> <p>I have a DataTemplate defined in my resources as follows :</p> <pre><code> &lt;UserControl.Resources&gt; &lt;ResourceDictionary&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;ResourceDictionary Source="../ParameterEditorResourceDictionary.xaml"&gt;&lt;/ResourceDictionary&gt; &lt;ResourceDictionary&gt; &lt;DataTemplate x:Key="ParameterDefault"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="("&gt;&lt;/TextBlock&gt; &lt;ItemsControl ItemsSource="{//I need to set from code}"&gt; //some code here &lt;/ItemsControl&gt; &lt;TextBlock Text=")"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ResourceDictionary&gt; &lt;/ResourceDictionary.MergedDictionaries&gt; &lt;/ResourceDictionary&gt; &lt;/UserControl.Resources&gt; </code></pre> <p>I have a DataGrid defined in my xaml which has a loaded event. </p> <pre><code> &lt;cc:PEDataGrid AutoGenerateColumns="False" Loaded="CommonPEGrid_Loaded"&gt; &lt;/cc:PEDataGrid&gt; </code></pre> <p>In my event handler code I want to set the ItemsSource of ItemsControl defined in my DataTemplate. My code behind looks like this :</p> <pre><code>private void CommonPEGrid_Loaded(object sender, RoutedEventArgs e) { int i = 0; DataGrid dg = sender as DataGrid; DataGridTemplateColumn column = null; //ParametersAllLoops is a ObservableCollection foreach (ParameterLoop obj in ParametersAllLoops) { column = new DataGridTemplateColumn(); column.Header = "Loop ( " + i.ToString() + " )"; DataTemplate dt = null; //Here I want to write code //I want to access the DataTemplate defined in resources //and set the ItemsSource of ItemsControl to something like this // xxx.ItemsSource = obj; and then assign the DataTemplate to //the CellTemplate of column. //**Note :: ParameterLoop object has the IList Parameters** column.CellTemplate = dt; dg.Columns.Add(column); i++; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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