Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-style-controls-on-a-toolbar.md
T
Andy (Steve) De George e9fcf43083 Merge pull request #1135 from dotnet/adegeo-links
Correct .NET Framework links that pointed to old .NET 5 URLs
2021-08-11 12:04:34 -07:00

40 lines
1.7 KiB
Markdown

---
title: "How to: Style Controls on a ToolBar"
ms.date: "03/30/2017"
helpviewer_keywords:
- "styling controls on toolbar [WPF]"
- "toolbars [WPF]"
- "customizing controls on toolbar [WPF]"
ms.assetid: ba6ae056-d6a9-4c24-90f8-467ab0bc0b1a
---
# How to: Style Controls on a ToolBar
The <xref:System.Windows.Controls.ToolBar> defines <xref:System.Windows.ResourceKey> objects to specify the style of controls within the <xref:System.Windows.Controls.ToolBar>. To style a control in a <xref:System.Windows.Controls.ToolBar>, set the `x:key` attribute of the style to a <xref:System.Windows.ResourceKey> defined in <xref:System.Windows.Controls.ToolBar>.
The <xref:System.Windows.Controls.ToolBar> defines the following <xref:System.Windows.ResourceKey> objects:
- <xref:System.Windows.Controls.ToolBar.ButtonStyleKey%2A>
- <xref:System.Windows.Controls.ToolBar.CheckBoxStyleKey%2A>
- <xref:System.Windows.Controls.ToolBar.ComboBoxStyleKey%2A>
- <xref:System.Windows.Controls.ToolBar.MenuStyleKey%2A>
- <xref:System.Windows.Controls.ToolBar.RadioButtonStyleKey%2A>
- <xref:System.Windows.Controls.ToolBar.SeparatorStyleKey%2A>
- <xref:System.Windows.Controls.ToolBar.TextBoxStyleKey%2A>
- <xref:System.Windows.Controls.ToolBar.ToggleButtonStyleKey%2A>
## Example
The following example defines styles for the controls within a <xref:System.Windows.Controls.ToolBar>.
[!code-xaml[ToolBar_snip#ToolBarAllStyles](~/samples/snippets/csharp/VS_Snippets_Wpf/ToolBar_snip/CS/pane1.xaml#toolbarallstyles)]
[!code-xaml[ToolBar_snip#ToolBar](~/samples/snippets/csharp/VS_Snippets_Wpf/ToolBar_snip/CS/pane1.xaml#toolbar)]
## See also
- [Styling and Templating](styles-templates-overview.md)