Sharing a Style : Style « Windows Presentation Foundation « C# / C Sharp






Sharing a Style

Sharing a Style
      

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="RSS Reader">
      
    <StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Orientation="Horizontal">
      <StackPanel.Resources>
        <Style x:Key="controlStyle">
          <Setter Property="Control.FontSize" Value="22"/>
          <Setter Property="Control.Background" Value="Purple"/>
          <Setter Property="Control.Foreground" Value="White"/>
          <Setter Property="Control.Height" Value="50"/>
          <Setter Property="Control.Width" Value="50"/>
          <Setter Property="Control.RenderTransformOrigin" Value=".5,.5"/>
          <Setter Property="Control.RenderTransform">
            <Setter.Value>
              <RotateTransform Angle="10"/>
            </Setter.Value>
          </Setter>
        </Style>
      </StackPanel.Resources>
      <ComboBox Style="{StaticResource controlStyle}">
        <ComboBox.Items>2</ComboBox.Items>
      </ComboBox>
      <Expander Style="{StaticResource controlStyle}" Content="3"/>
      <TabControl Style="{StaticResource controlStyle}">
        <TabControl.Items>4</TabControl.Items>
      </TabControl>
      <ToolBar Style="{StaticResource controlStyle}">
        <ToolBar.Items>5</ToolBar.Items>
      </ToolBar>
      <InkCanvas Style="{StaticResource controlStyle}"/>
      <TextBox Style="{StaticResource controlStyle}" Text="7"/>
    </StackPanel>

</Window>

   
    
    
    
    
    
  








Related examples in the same category

1.Double value as the Font sizeDouble value as the Font size
2.FontFamily resource constantFontFamily resource constant
3.Styles With Same KeysStyles With Same Keys
4.Setter With Binding to SliderSetter With Binding to Slider
5.Style With Data TriggerStyle With Data Trigger
6.Styles With Target TypesStyles With Target Types
7.Style With Multiple ElementsStyle With Multiple Elements
8.Style With Multiple ButtonsStyle With Multiple Buttons
9.Style With ResourceStyle With Resource
10.Style With Property ElementStyle With Property Element
11.Style With TriggersStyle With Triggers
12.Style Slider: Background, IsSnapToTickEnabled, AutoToolTipPlacement, TickFrequencyStyle Slider: Background, IsSnapToTickEnabled, AutoToolTipPlacement, TickFrequency
13.Normal: Origin at upper leftNormal: Origin at upper left
14.Stroke Start Line CapStroke Start Line Cap
15.Property TriggerProperty Trigger
16.Using a Style resourceUsing a Style resource
17.Ignore an Implicit Style by setting Style to NullIgnore an Implicit Style by setting Style to Null
18.Set a Style ProgrammaticallySet a Style Programmatically
19.extends StyleSelector to create your own style selectorextends StyleSelector to create your own style selector
20.The default GroupStyle indents the items in a groupThe default GroupStyle indents the items in a group