Note that there are some explanatory texts on larger screens.

plurals
  1. POData template switching based on trigger
    text
    copied!<p>I'm having the same problem as described here : <a href="https://stackoverflow.com/questions/2565859/contenttemplateselector-is-only-called-one-time-showing-always-the-same-datatempl">ContentTemplateSelector is only called one time showing always the same datatemplate</a></p> <p>I've attempted the same solution as Simon Weaver suggests (although his answer is somewhat abbreviated so i'm guessing it looks like the following):</p> <pre><code>&lt;ContentControl &gt; &lt;Style&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding Path=IsSelected}" Value="true"&gt; &lt;Setter Value="{StaticResource SelectedDataTemplate}" Property="ContentControl.ContentTemplate"&gt;&lt;/Setter&gt; &lt;/DataTrigger&gt; &lt;DataTrigger Binding="{Binding Path=IsSelected}" Value="false"&gt; &lt;Setter Value="{StaticResource UnSelectedDataTemplate}" Property="ContentControl.ContentTemplate"&gt; &lt;/Setter&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/ContentControl&gt; </code></pre> <p>However when i run this, i just get 'System.Windows.Style' displayed in my content control. As an aside, i've (sort of) got it working using an overridden DataTemplateSelector class, but the problem there is that the selector only gets evaluated on start up. I need this switching behaviour based on the data bound IsSelected property - which i was hoping the above snippet achieves. BTW the actual data templates themselves just contain UI stuff - no data triggers etc so i'm not including them in my post.</p>
 

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