wpf - Change ControlTemplate from a Trigger in .xaml file -


There are some control templates defined with the CR key and they are applied through a trigger

   

& lt; ControlTemplate x: key = "{ComponentResourceKey ResourceId = SubmenuItemTemplateKey, TypeInTargetAssembly = {x: Type MenuItem}}" TargetType = "{x: Type MenuItem}" & gt; & Lt; Grid Snap ToDevice Pixel = "True" & gt; .... & lt; / ControlTemplate & gt;

and these templates apply via trigger

   & Lt; Style.Triggers & gt; & Lt; Trigger Property = "Role" Value = "Top-Level Header" & gt; & Lt; Setter Property = "Template" value = "{dynamic resource {ComponentResourceKey ResourceId = TopLevelHeaderTemplateKey, TypeInTargetAssembly = {x: Type MenuItem}}} /> 
Lt; / Trigger & gt; ... & lt; / Style Triggers & Amp; gg; & lt; / style & gt;

This works, but I do not want the control template to be the default in the app, and instead control them through a key

   ControlTemplate X: key = "submenuimetapplette" target type = "{x: type i Nuitum} "& gt; Grid snap todive pixel =" true "& gt; ...   

For some reasons, the trigger should be directly controlled ControlTemplates can not be found when referenced through

  & lt; style x: key = "{x: static keys: Menu .DefaultItemContainerStyle}" TargetType = "{x: Type MenuItem}" & gt; ; & Lt; Setter Property = "Template" value = "{DynamicResource SubmenuItemTemplateKey}" /> StyleTriggers & gt; Trigger Property = "Role" Value = "Top-Level Header" & gt; ; & Lt; Setter property = "Template" value = "{DynamicResource TopLevelHeaderTemplateKey}" /> & Lt; / Catalyst & gt; ... & lt; / Style Triggers & amp; Gg; & Lt; / Style & gt;  


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -