Default MenuItem TopLevelHeader Management Template

Where can I get the MenuItem TopLevelHeader control template? The MSDN link for style menu items gives a modified template.

alt text

I need to get a control template containing a popup / context menu by default.

+4
source share
2 answers

Manny tools are available to be used as stylesnooper and show me the template

but if you have Microsoft Expression Blend , you can extract the default management template

  • Drag the control onto the Surface design
  • Right-click the control and select Modify Template → Modify Copy

When you do this, Blend will extract the base template from the control and explicitly declare it in the document / application as a resource, which you can then edit to your liking.

Check it out for more

http://www.shafqatahmed.com/2009/01/wpf-kid-stuff-extracting-a-control-template.html

+2
source

I could not get Blend or the usual tools to access this control template, but you can extract it yourself with the code, as shown below:

var controlTemplate = (ControlTemplate)FindResource(MenuItem.TopLevelHeaderTemplateKey); var sb = new StringBuilder(); var xml = XmlWriter.Create(sb, new XmlWriterSettings { Indent = true, NewLineOnAttributes = true }); XamlWriter.Save(controlTemplate, xml); var xaml = sb.ToString(); Debug.WriteLine(xaml); 

The output is too long to be included here.

+1
source

Source: https://habr.com/ru/post/1333631/


All Articles