ToolBar.ButtonStyleKey : ToolBar « Windows Presentation Foundation « C# / CSharp Tutorial






<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Background="White">
  <Window.Resources>
    <Style x:Key="{x:Static ToolBar.SeparatorStyleKey}" TargetType="Separator">
      <Setter Property="Background" Value="DarkBlue"/>
      <Setter Property="Width" Value="2"/>
    </Style>

    <Style x:Key="{x:Static ToolBar.ButtonStyleKey}" TargetType="Button">
      <Setter Property="Foreground" Value="Blue"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>

    <Style x:Key="{x:Static ToolBar.CheckBoxStyleKey}" TargetType="CheckBox">
      <Setter Property="Foreground" Value="DarkSlateBlue"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>
    
    <Style x:Key="{x:Static ToolBar.MenuStyleKey}" TargetType="Menu">
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="FontStyle" Value="Italic"/>
      <Setter Property="FontWeight" Value="Bold"/>
      <Setter Property="Background" Value="LightSteelBlue"/>
    </Style>
    
    <Style x:Key="{x:Static ToolBar.RadioButtonStyleKey}" TargetType="RadioButton">
      <Setter Property="Background" Value="LightSteelBlue"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>
   
    <Style x:Key="{x:Static ToolBar.TextBoxStyleKey}" TargetType="TextBox">
      <Setter Property="Background" Value="DarkBlue"/>
      <Setter Property="Foreground" Value="White"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="FontStyle" Value="Italic"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
      <Setter Property="Width" Value="75"/>
    </Style>
    
    <Style x:Key="{x:Static ToolBar.ComboBoxStyleKey}" TargetType="ComboBox">
      <Setter Property="Background" Value="LightSteelBlue"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="MinWidth" Value="60"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>
    
    <Style TargetType="Separator">
      <Setter Property="Background" Value="DarkBlue"/>
      <Setter Property="Width" Value="2"/>
    </Style>

    <Style TargetType="Button">
      <Setter Property="Foreground" Value="Blue"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>

    <Style TargetType="CheckBox">
      <Setter Property="Foreground" Value="DarkSlateBlue"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>

    <Style TargetType="Menu">
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="FontStyle" Value="Italic"/>
      <Setter Property="FontWeight" Value="Bold"/>
      <Setter Property="Background" Value="LightSteelBlue"/>
    </Style>

    <Style TargetType="RadioButton">
      <Setter Property="Background" Value="LightSteelBlue"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>

    <Style TargetType="TextBox">
      <Setter Property="Background" Value="DarkBlue"/>
      <Setter Property="Foreground" Value="White"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="FontStyle" Value="Italic"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
      <Setter Property="Width" Value="75"/>
    </Style>

    <Style TargetType="ComboBox">
      <Setter Property="Background" Value="LightSteelBlue"/>
      <Setter Property="FontSize" Value="14"/>
      <Setter Property="MinWidth" Value="60"/>
      <Setter Property="HorizontalAlignment" Value="Center"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>
  </Window.Resources>

  <StackPanel>
    <ToolBarTray Margin="10,10,3,3" 
                 Grid.Column="0" Grid.Row="2"
                 Background="LightBlue">
      <ToolBar >
        <Button Content="Button 1"/>
        <Button Content="Button 2"/>
        <Separator/>
        <CheckBox Content="CheckBox 1"/>
        <CheckBox Content="CheckBox 2"/>
        <Separator/>
        <RadioButton>One</RadioButton>
        <RadioButton>Two</RadioButton>
        <Separator/>
        <ComboBox>
          <ComboBoxItem IsSelected="True">Item 1</ComboBoxItem>
          <ComboBoxItem>Item 2</ComboBoxItem>
          <ComboBoxItem>Item 3</ComboBoxItem>
          <ComboBoxItem>Item 4</ComboBoxItem>
        </ComboBox>
        <TextBox/>
        <Separator/>
        <Menu>
          <MenuItem Header="Menu">
            <MenuItem Header="File">
              <MenuItem Header="Copy"/>
              <MenuItem Header="Paste"/>
            </MenuItem>
          </MenuItem>
        </Menu>
      </ToolBar>
    </ToolBarTray>


  </StackPanel>
</Window>
WPF Tool Bar Button Style Key








24.49.ToolBar
24.49.1.ToolBar.ButtonStyleKeyToolBar.ButtonStyleKey
24.49.2.Compare the appearances of these controls with the ones in the ToolBar.Compare the appearances of these controls with the ones in the ToolBar.
24.49.3.Toolbar TraysToolbar Trays
24.49.4.Basic ToolbarBasic Toolbar
24.49.5.ToolBarTrayToolBarTray
24.49.6.ToolBar in a ToolBarTrayToolBar in a ToolBarTray
24.49.7.ToolBar button with Customized paintingToolBar button with Customized painting
24.49.8.ToolBarTray and ToolBarToolBarTray and ToolBar
24.49.9.Display a ToolbarDisplay a Toolbar
24.49.10.ToolBar and Button, ToggleButton, ComboBox and SeparatorToolBar and Button, ToggleButton, ComboBox and Separator
24.49.11.Create ToolBar and set header value