WinRT - I can't find Triggers/EventTriggers/DataTriggers in Styles and ControlTemplates in WinRT?


(Kunni Can) #1

I’ve just switched to WinRT, and seems like there is are no Triggers of any kind (Triggers, EventTriggers, DataTriggers…etc), in Styles, ControlTemplates and controls themselves. did i do anything wrong, or there is another alternative to that?

i am using VS2015 and WinRT for windows 8.1

(jms) #2

Yep, that’s one of the many things that aren’t the same in WinRT and WPF, (Triggers). in WinRT there is NO more triggers, instead you use VisualStateManager, the good news is that Visual Studio 2015, came up with a much better alternative, which is replacing the entire Control’s UI Template/Style. and here is how to do it:

  1. After adding your Control to a VisualStudio 2015, WinRT Page (let’s say a Button).
  2. Click Right mouse button over that control in the designer.
  3. Go to “Edit Template” or “Edit Additional Templates” depending on what you wish to re-style:
  • "Edit Template": In case you want to change the entire control Visual Style.
  • "Edit Additional Templates": In order to change other associated components (such as Headers, Footers,…etc) if any exist.
  1. Then click the “Edit a Copy” Item, that will Generate the full Style XAML for you, and then you can manually change the colors, and behavior as you wish. Plus it can be a good learning tool, to understand how the Standard WinRT Controls are styled.

I hope that helps.