visual-studio - 如何在没有 Visual Studio 设计器的情况下查看 XAML 控件的默认模板和样式?

标签 visual-studio xaml uwp windows-runtime

根据 MSDN 上的控件模板文档,官方支持的查看控件默认模板和样式的方法是使用 Visual Studio 设计器(嗯,从技术上讲,文档大纲>,但这仅适用于打开设计器的情况):

A fast way to apply themes to your controls is to right-click on a control on the Microsoft Visual Studio Document Outline and select Edit Theme or Edit Style (depending on the control you are right-clicking on). You can then apply an existing theme by selecting Apply Resource or define a new one by selecting Create Empty.

[...]

The topics that document the styles and templates for XAML controls show you excerpts of the same starting XAML you'd see if you used the Edit Theme or Edit Style techniques explained previously. Each topic lists the names of the visual states, the theme resources used, and the full XAML for the style that contains the template. The topics can be useful guidance if you've already started modifying a template and want to see what the original template looked like, or to verify that your new template has all of the required named visual states.

但是,开发人员可能无权访问 Visual Studio 设计器。

我必须使用哪些官方、保证最新的替代方案来查看默认模板和样式?

谢谢!

免责声明:我在 Microsoft 工作。

最佳答案

您可以在generic.xaml文件中找到控件的默认样式。

  • 如果自动完成/IntelliSense 在您的 Visual Studio 中运行:

    1. 创建一个使用内置样式的控件,例如 Style="{StaticResource ButtonRevealStyle}"
    2. 将指针悬停在 ButtonRevealStyle 上,然后按 F12 或右键单击并选择转到定义选项以访问 generic.xaml
    3. generic.xaml 中,您可以在搜索框中使用诸如 Default style for Windows.UI.Xaml.Controls.Button 之类的语句来搜索默认样式查找 Button 控件的默认样式。

    注意,如果您不需要样式ButtonRevealStyle,请删除语句Style="{StaticResource ButtonRevealStyle}"

  • 您还可以找到该文件作为 Windows SDK 的一部分。它位于 C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.18362.0\Generic (其中 10.0.18362.0 是SDK的版本,您可以将其替换为您正在使用的版本)。

关于visual-studio - 如何在没有 Visual Studio 设计器的情况下查看 XAML 控件的默认模板和样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64932733/

相关文章:

c# - .netstandard 库和 UniversalApiContract

uwp - 使用 Windows.Services.Store Addons 模拟购买

visual-studio - 在Unity3D中单击角色时创建弹出菜单Sims的样式

C# 花括号格式化 Visual Studio 2017

c# - XamlReader.Parse 在空字符串上引发异常

silverlight - 在 XAML 中的一个 TextBlock 中格式化多个绑定(bind)字段

c# - 打包个人 Windows 通用应用程序 windows.fullTrustProcess

c++ - 如何在 rc 文件中设置对话框代码页

visual-studio - 如何从 Visual Studio 2008 解决方案导出类列表

xaml - 为 Windows 应用商店应用学习 xaml 的最佳资源?