如何在Visual Studio中提取默认控件模板? [英] How to Extract Default Control Template In Visual Studio?
问题描述
我想知道如何使用Visual Studio提取(获取副本)给定控件的默认模板.我知道这可以通过Expression Blend(右键单击控件,编辑模板"->编辑副本...")完成,然后将默认控件模板复制到Xaml中.但是,可以完全使用Visual Studio做到这一点吗?
I'm wondering how I can extract (get a copy) of the Default Template of a given control using Visual Studio. I know this can be done with Expression Blend (right click a control, "Edit Template" -> "Edit a Copy...") which then copies the default control template in my Xaml. But can this be done with Visual Studio at all?
推荐答案
2015年更新,带有明确说明
2015 update with clear instructions
在Visual Studio 2013中,只需几个简单的步骤即可获得控件的默认ControlTemplate
.
In Visual Studio 2013, you can get the default ControlTemplate
of a control in a few simple steps.
-
在WPF设计器中,选择相关控件,或将鼠标光标放在XAML中的相关控件上.
In the WPF designer, select the relevant control, or place the mouse cursor on the relevant control in the XAML.
按 F4 打开属性"窗口.
打开其他类别以找到 Template 属性,或在窗口顶部的搜索字段中键入 Template .
Open the Miscellaneous category to find the Template property, or type Template in the search field at the top of the Window.
单击 Template 字段右侧的小方块,然后选择转换为新资源... 选项:
Click on the little square to the right of the Template field and select the Convert to New Resource... option:
- 在弹出对话框中,命名要添加的新
ControlTemplate
并确定要在何处定义它:
- In the popup dialog, name the new
ControlTemplate
to be added and decide where you want it to be defined:
- 点击确定按钮.
这篇关于如何在Visual Studio中提取默认控件模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!