Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF: Unable to access static resource from child control
    primarykey
    data
    text
    <p>I cannot find out how to access my Window.Resources from inside a child control's Resource section. I have a DataTemplate being defined in the child control, and want that DataTemplate to bind to an ICommand on my view model (defined in Window.Resources)</p> <p><em>EDIT:</em> I added my <code>RadPaneGroup</code> code to the Main Window XAML. This is where I instantiate the <code>ProjectsViewModel</code> object. The <code>ProjectsView</code> control contained in the <code>RadDocumentPane</code> is the Child Control I have listed below.</p> <p><strong>Main Window</strong></p> <pre><code>&lt;Window.Resources&gt; &lt;viewModels:ProjectsViewModel x:Key="ProjectsViewModel" /&gt; &lt;/Window.Resources&gt; &lt;telerik:RadDocking HasDocumentHost="False" &gt; &lt;telerik:RadSplitContainer&gt; &lt;telerik:RadPaneGroup DataContext="{StaticResource ProjectsViewModel}"&gt; &lt;telerik:RadDocumentPane Header="Projects"&gt; &lt;views:ProjectsView/&gt; &lt;/telerik:RadDocumentPane&gt; &lt;/telerik:RadPaneGroup&gt; &lt;/telerik:RadSplitContainer&gt; ... </code></pre> <p><strong>Child Control</strong></p> <pre><code>&lt;Control.Resources&gt; &lt;!--Data template for the Task object--&gt; &lt;DataTemplate DataType="{x:Type models:Task}"&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding DisplayName}" Foreground="Red" FontSize="16" FontFamily="Verdana" /&gt; &lt;telerik:RadContextMenu.ContextMenu&gt; &lt;telerik:RadContextMenu &gt; &lt;telerik:RadMenuItem Header="New Project" Command="{Binding NewProjectCommand}"/&gt; &lt;/telerik:RadContextMenu&gt; &lt;/telerik:RadContextMenu.ContextMenu&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; </code></pre> <p>The binding on the above XAML is trying to bind to the Task object. However, my ICommand is located in the ViewModel (ProjectsViewModel). I've tried to change the binding to <code>Command="{Binding NewProjectCommand, Source={StaticResource ProjectsViewModel}}</code> but this throws an exception.</p> <p>What am I doing wrong?</p> <p>Thanks,</p>
    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.
 

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