Control 样式和模板Control Styles and Templates

Windows Presentation Foundation (WPF)中的控件具有一个包含该控件的可视化树的 ControlTemplateControls in Windows Presentation Foundation (WPF) have a ControlTemplate that contains the visual tree of that control. 可以通过修改控件的 ControlTemplate 来更改该控件的结构和外观。You can change the structure and appearance of a control by modifying the ControlTemplate of that control. 无法仅替换控件的可视化树的一部分;若要更改控件的可视化树,必须将控件的 Template 属性设置为其新的和完整的 ControlTemplateThere is no way to replace only part of the visual tree of a control; to change the visual tree of a control you must set the Template property of the control to its new and complete ControlTemplate.

桌面主题确定使用的资源字典。The desktop themes determine which resource dictionary is used. 若要为桌面主题获取资源字典,请参阅默认的 WPF 主题To get the resource dictionaries for the desktop themes, see Default WPF Themes.

下表描述了资源字典文件名及其相应的桌面主题。The following table describes the resource dictionary file names and their corresponding desktop themes.

主题文件Theme file 桌面主题Desktop theme
Classic.xamlClassic.xaml Windows XP 操作系统上的经典 Windows 外观(Windows 95、Windows 98 和 Windows 2000)。Classic Windows look (from Windows 95, Windows 98, and Windows 2000) on the Windows XP operating system..
Luna.NormalColor.xamlLuna.NormalColor.xaml Windows XP 上的默认蓝色主题。Default blue theme on Windows XP.
Luna.Homestead.xamlLuna.Homestead.xaml Windows XP 上的橄榄色主题。Olive theme on Windows XP.
Luna.Metallic.xamlLuna.Metallic.xaml Windows XP 上的银色主题。Silver theme on Windows XP.
Royale.NormalColor.xamlRoyale.NormalColor.xaml Windows XP Media Center Edition 操作系统上的默认主题。Default theme on the Windows XP Media Center Edition operating system.
Aero.NormalColor.xamlAero.NormalColor.xaml Windows Vista 操作系统上的默认主题。Default theme on the Windows Vista operating system.

本节内容In This Section

Button 样式和模板Button Styles and Templates
Calendar 样式和模板Calendar Styles and Templates
CheckBox 样式和模板CheckBox Styles and Templates
ComboBox 样式和模板ComboBox Styles and Templates
ContextMenu 样式和模板ContextMenu Styles and Templates
DataGrid 样式和模板DataGrid Styles and Templates
DatePicker 样式和模板DatePicker Styles and Templates
DocumentViewer 样式和模板DocumentViewer Styles and Templates
Expander 样式和模板Expander Styles and Templates
Frame 样式和模板Frame Styles and Templates
GroupBox 样式和模板GroupBox Styles and Templates
Label 样式和模板Label Styles and Templates
ListBox 样式和模板ListBox Styles and Templates
ListView 样式和模板ListView Styles and Templates
Menu 样式和模板Menu Styles and Templates
NavigationWindow 样式和模板NavigationWindow Styles and Templates
PasswordBox 样式和模板PasswordBox Styles and Templates
ProgressBar 样式和模板ProgressBar Styles and Templates
RadioButton 样式和模板RadioButton Styles and Templates
RepeatButton 样式和模板RepeatButton Styles and Templates
ScrollBar 样式和模板ScrollBar Styles and Templates
ScrollViewer 样式和模板ScrollViewer Styles and Templates
Slider 样式和模板Slider Styles and Templates
StatusBar 样式和模板StatusBar Styles and Templates
TabControl 样式和模板TabControl Styles and Templates
TextBox 样式和模板TextBox Styles and Templates
Thumb 样式和模板Thumb Styles and Templates
切换按钮样式和模板ToggleButton Styles and Templates
ToolBar 样式和模板ToolBar Styles and Templates
ToolTip 样式和模板ToolTip Styles and Templates
TreeView 样式和模板TreeView Styles and Templates
Window 样式和模板Window Styles and Templates

参考Reference

System.Windows.Controls

ControlTemplate

控件创作概述Control Authoring Overview

样式设置和模板化Styling and Templating