sammarks

XAML Example

Nov 26th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 14.29 KB | None | 0 0
  1. <ResourceDictionary
  2.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  4.    
  5.     <!-- Define Style Colors -->
  6.     <Color x:Key="GlobalAccent-Color">#FF333333</Color>
  7.     <Color x:Key="PrimaryForeground-Color">#FF333333</Color>
  8.     <Color x:Key="PrimaryForegroundInactive-Color">#FF666666</Color>
  9.     <Color x:Key="PrimaryForegroundActive-Color">#FF000000</Color>
  10.     <Color x:Key="SecondaryForeground-Color">#FFCCCCCC</Color>
  11.     <Color x:Key="SecondaryForegroundActive-Color">#FFFFFFFF</Color>
  12.     <Color x:Key="NavBackground-Color">#FF666666</Color>
  13.     <Color x:Key="NavForegroundNonActive-Color">#FFCCCCCC</Color>
  14.     <Color x:Key="NavForegroundActive-Color">#FFFFFFFF</Color>
  15.     <Color x:Key="Background-Color">#FFEEEEEE</Color>
  16.     <SolidColorBrush x:Key="GlobalAccent" Color="{StaticResource GlobalAccent-Color}" />
  17.     <SolidColorBrush x:Key="PrimaryForeground" Color="{StaticResource PrimaryForeground-Color}" />
  18.     <SolidColorBrush x:Key="PrimaryForegroundInactive" Color="{StaticResource PrimaryForegroundInactive-Color}" />
  19.     <SolidColorBrush x:Key="PrimaryForegroundActive" Color="{StaticResource PrimaryForegroundActive-Color}" />
  20.     <SolidColorBrush x:Key="SecondaryForeground" Color="{StaticResource SecondaryForeground-Color}" />
  21.     <SolidColorBrush x:Key="SecondaryForegroundActive" Color="{StaticResource SecondaryForegroundActive-Color}" />
  22.     <SolidColorBrush x:Key="NavBackground" Color="{StaticResource NavBackground-Color}" />
  23.     <SolidColorBrush x:Key="NavForegroundNonActive" Color="{StaticResource NavForegroundNonActive-Color}" />
  24.     <SolidColorBrush x:Key="NavForegroundActive" Color="{StaticResource NavForegroundActive-Color}" />
  25.     <SolidColorBrush x:Key="Background" Color="{StaticResource Background-Color}" />
  26.    
  27.     <!-- Global fields -->
  28.     <Duration x:Key="HoverDuration">0:0:0.1</Duration>
  29.    
  30.     <!-- Header Button Style -->
  31.     <Style x:Key="HeaderWindowAction" TargetType="{x:Type Grid}">
  32.         <Setter Property="Background" Value="{StaticResource GlobalAccent}" />
  33.         <Setter Property="OpacityMask" Value="{StaticResource SecondaryForeground}" />
  34.         <Setter Property="Cursor" Value="Hand" />
  35.         <Style.Triggers>
  36.             <EventTrigger RoutedEvent="MouseEnter">
  37.                 <BeginStoryboard>
  38.                     <Storyboard Storyboard.TargetProperty="OpacityMask.Color">
  39.                         <ColorAnimation From="{StaticResource SecondaryForeground-Color}" To="{StaticResource SecondaryForegroundActive-Color}" Duration="{StaticResource HoverDuration}" />
  40.                     </Storyboard>
  41.                 </BeginStoryboard>
  42.             </EventTrigger>
  43.             <EventTrigger RoutedEvent="MouseLeave">
  44.                 <BeginStoryboard>
  45.                     <Storyboard Storyboard.TargetProperty="OpacityMask.Color">
  46.                         <ColorAnimation From="{StaticResource SecondaryForegroundActive-Color}" To="{StaticResource SecondaryForeground-Color}" Duration="{StaticResource HoverDuration}" />
  47.                     </Storyboard>
  48.                 </BeginStoryboard>
  49.             </EventTrigger>
  50.         </Style.Triggers>
  51.     </Style>
  52.     <Style x:Key="HeaderAction" TargetType="{x:Type Label}" BasedOn="{StaticResource SimpleLabel}">
  53.         <Setter Property="Background" Value="{StaticResource GlobalAccent}" />
  54.         <Setter Property="FontWeight" Value="SemiBold" />
  55.         <Setter Property="FontSize" Value="7.5pt" />
  56.         <Setter Property="Foreground" Value="{StaticResource SecondaryForeground}" />
  57.         <Setter Property="Cursor" Value="Hand" />
  58.         <Setter Property="BorderBrush" Value="{StaticResource SecondaryForeground}" />
  59.         <Setter Property="BorderThickness" Value="1, 0, 0, 0" />
  60.         <Setter Property="Margin" Value="0, 0, 5, 0" />
  61.         <Setter Property="Padding" Value="5, 1, 0, 1" />
  62.         <Setter Property="VerticalAlignment" Value="Center" />
  63.         <Style.Triggers>
  64.             <EventTrigger RoutedEvent="MouseEnter">
  65.                 <BeginStoryboard>
  66.                     <Storyboard Storyboard.TargetProperty="Foreground.Color">
  67.                         <ColorAnimation From="{StaticResource SecondaryForeground-Color}" To="{StaticResource SecondaryForegroundActive-Color}" Duration="{StaticResource HoverDuration}" />
  68.                     </Storyboard>
  69.                 </BeginStoryboard>
  70.             </EventTrigger>
  71.             <EventTrigger RoutedEvent="MouseLeave">
  72.                 <BeginStoryboard>
  73.                     <Storyboard Storyboard.TargetProperty="Foreground.Color">
  74.                         <ColorAnimation From="{StaticResource SecondaryForegroundActive-Color}" To="{StaticResource SecondaryForeground-Color}" Duration="{StaticResource HoverDuration}" />
  75.                     </Storyboard>
  76.                 </BeginStoryboard>
  77.             </EventTrigger>
  78.         </Style.Triggers>
  79.     </Style>
  80.    
  81.     <!-- Navigation Styles -->
  82.     <Style x:Key="NavigationItem" TargetType="{x:Type Label}">
  83.         <Setter Property="Padding" Value="0" />
  84.         <Setter Property="Margin" Value="0, -7, 20, 0" />
  85.         <Setter Property="FontSize" Value="30px" />
  86.         <Setter Property="Foreground" Value="{StaticResource NavForegroundNonActive}" />
  87.         <Setter Property="Background" Value="{x:Null}" />
  88.         <Setter Property="Cursor" Value="Hand" />
  89.         <Setter Property="FontWeight" Value="300" />
  90.         <Setter Property="VerticalAlignment" Value="Center" />
  91.         <Style.Triggers>
  92.             <EventTrigger RoutedEvent="MouseEnter">
  93.                 <BeginStoryboard>
  94.                     <Storyboard Storyboard.TargetProperty="Foreground.Color">
  95.                         <ColorAnimation From="{StaticResource NavForegroundNonActive-Color}" To="{StaticResource NavForegroundActive-Color}" Duration="{StaticResource HoverDuration}" />
  96.                     </Storyboard>
  97.                 </BeginStoryboard>
  98.             </EventTrigger>
  99.             <EventTrigger RoutedEvent="MouseLeave">
  100.                 <BeginStoryboard>
  101.                     <Storyboard Storyboard.TargetProperty="Foreground.Color">
  102.                         <ColorAnimation From="{StaticResource NavForegroundActive-Color}" To="{StaticResource NavForegroundNonActive-Color}" Duration="{StaticResource HoverDuration}" />
  103.                     </Storyboard>
  104.                 </BeginStoryboard>
  105.             </EventTrigger>
  106.         </Style.Triggers>
  107.     </Style>    
  108.     <Style x:Key="NavigationItemActive" TargetType="{x:Type Label}">
  109.         <Setter Property="Padding" Value="0" />
  110.         <Setter Property="Margin" Value="0, -7, 20, 0" />
  111.         <Setter Property="FontSize" Value="30px" />
  112.         <Setter Property="Foreground" Value="{StaticResource NavForegroundActive}" />
  113.         <Setter Property="Background" Value="{x:Null}" />
  114.         <Setter Property="FontWeight" Value="300" />
  115.         <Setter Property="VerticalAlignment" Value="Center" />
  116.     </Style>
  117.    
  118.     <!-- Settings Screen Styles -->
  119.     <Style x:Key="SettingsMenuItem" TargetType="{x:Type Label}">
  120.         <Setter Property="Padding" Value="0, 5, 10, 5" />
  121.         <Setter Property="Foreground" Value="{DynamicResource PrimaryForegroundInactive}" />
  122.         <Setter Property="Background" Value="#00FFFFFF" />
  123.         <Setter Property="FontSize" Value="15px" />
  124.         <Setter Property="FontWeight" Value="SemiBold" />
  125.         <Setter Property="HorizontalContentAlignment" Value="Right" />
  126.         <Setter Property="Width" Value="Auto" />
  127.         <Setter Property="Cursor" Value="Hand" />
  128.         <Style.Triggers>
  129.             <EventTrigger RoutedEvent="MouseEnter">
  130.                 <BeginStoryboard>
  131.                     <Storyboard Storyboard.TargetProperty="Foreground.Color">
  132.                         <ColorAnimation From="{StaticResource PrimaryForegroundInactive-Color}" To="{StaticResource PrimaryForegroundActive-Color}" Duration="{StaticResource HoverDuration}" />
  133.                     </Storyboard>
  134.                 </BeginStoryboard>
  135.             </EventTrigger>
  136.             <EventTrigger RoutedEvent="MouseLeave">
  137.                 <BeginStoryboard>
  138.                     <Storyboard Storyboard.TargetProperty="Foreground.Color">
  139.                         <ColorAnimation From="{StaticResource PrimaryForegroundActive-Color}" To="{StaticResource PrimaryForegroundInactive-Color}" Duration="{StaticResource HoverDuration}" />
  140.                     </Storyboard>
  141.                 </BeginStoryboard>
  142.             </EventTrigger>
  143.         </Style.Triggers>
  144.     </Style>
  145.     <Style x:Key="SettingsMenuItem-Active" TargetType="{x:Type Label}">
  146.         <Setter Property="Padding" Value="0, 5, 10, 5" />
  147.         <Setter Property="Foreground" Value="{DynamicResource PrimaryForegroundActive}" />
  148.         <Setter Property="Background" Value="#00FFFFFF" />
  149.         <Setter Property="FontSize" Value="15px" />
  150.         <Setter Property="FontWeight" Value="SemiBold" />
  151.         <Setter Property="HorizontalContentAlignment" Value="Right" />
  152.         <Setter Property="Width" Value="Auto" />
  153.     </Style>
  154.    
  155.     <!-- Default Button Style -->
  156.     <Style x:Key="DefaultButton" TargetType="{x:Type Button}" BasedOn="{StaticResource SimpleButton}">
  157.         <Setter Property="Background" Value="#00FFFFFF" />
  158.         <Setter Property="Cursor" Value="Hand" />
  159.         <Setter Property="Padding" Value="5" />
  160.         <Setter Property="BorderThickness" Value="1, 0, 1, 0" />
  161.         <Setter Property="BorderBrush" Value="{DynamicResource PrimaryForeground}" />
  162.         <Setter Property="Foreground" Value="{DynamicResource PrimaryForeground}" />
  163.         <Setter Property="FontWeight" Value="SemiBold" />
  164.         <Setter Property="FontSize" Value="9pt" />
  165.         <Setter Property="Width" Value="85" />
  166.         <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  167.         <Style.Triggers>
  168.             <EventTrigger RoutedEvent="MouseEnter">
  169.                 <BeginStoryboard>
  170.                     <Storyboard Storyboard.TargetProperty="BorderThickness">
  171.                         <ThicknessAnimation From="1, 0, 1, 0" To="3, 0, 3, 0" Duration="{StaticResource HoverDuration}" />
  172.                     </Storyboard>
  173.                 </BeginStoryboard>
  174.                 <BeginStoryboard>
  175.                     <Storyboard Storyboard.TargetProperty="BorderBrush.Color">
  176.                         <ColorAnimation From="{StaticResource PrimaryForeground-Color}" To="{StaticResource PrimaryForegroundActive-Color}" Duration="{StaticResource HoverDuration}" />
  177.                     </Storyboard>
  178.                 </BeginStoryboard>
  179.                 <BeginStoryboard>
  180.                     <Storyboard Storyboard.TargetProperty="Foreground.Color">
  181.                         <ColorAnimation From="{StaticResource PrimaryForeground-Color}" To="{StaticResource PrimaryForegroundActive-Color}" Duration="{StaticResource HoverDuration}" />
  182.                     </Storyboard>
  183.                 </BeginStoryboard>
  184.             </EventTrigger>
  185.             <EventTrigger RoutedEvent="MouseLeave">
  186.                 <BeginStoryboard>
  187.                     <Storyboard Storyboard.TargetProperty="BorderThickness">
  188.                         <ThicknessAnimation To="1, 0, 1, 0" From="3, 0, 3, 0" Duration="{StaticResource HoverDuration}" />
  189.                     </Storyboard>
  190.                 </BeginStoryboard>
  191.                 <BeginStoryboard>
  192.                     <Storyboard Storyboard.TargetProperty="BorderBrush.Color">
  193.                         <ColorAnimation To="{StaticResource PrimaryForeground-Color}" From="{StaticResource PrimaryForegroundActive-Color}" Duration="{StaticResource HoverDuration}" />
  194.                     </Storyboard>
  195.                 </BeginStoryboard>
  196.                 <BeginStoryboard>
  197.                     <Storyboard Storyboard.TargetProperty="Foreground.Color">
  198.                         <ColorAnimation To="{StaticResource PrimaryForeground-Color}" From="{StaticResource PrimaryForegroundActive-Color}" Duration="{StaticResource HoverDuration}" />
  199.                     </Storyboard>
  200.                 </BeginStoryboard>
  201.             </EventTrigger>
  202.         </Style.Triggers>
  203.     </Style>
  204.  
  205.     <!-- Checkmark -->
  206.     <Style x:Key="DefaultCheckBox" TargetType="{x:Type CheckBox}">
  207.         <Setter Property="SnapsToDevicePixels" Value="true"/>
  208.         <Setter Property="Foreground" Value="{DynamicResource PrimaryForeground}" />
  209.         <Setter Property="Template">
  210.             <Setter.Value>
  211.                 <ControlTemplate TargetType="{x:Type CheckBox}">
  212.  
  213.                     <!-- BulletDecorator is used to provide baseline alignment between the checkmark and the Content -->
  214.                     <BulletDecorator Background="Transparent">
  215.                         <BulletDecorator.Bullet>
  216.                             <Grid Width="16" Height="16">
  217.                                 <Border x:Name="Border" BorderBrush="{TemplateBinding Foreground}" BorderThickness="2"/>
  218.                                 <Path x:Name="CheckMark" Stroke="{DynamicResource PrimaryForegroundActive}" StrokeThickness="2" SnapsToDevicePixels="False" Data="M1,1 L14,14" Margin="0" Stretch="Fill" VerticalAlignment="Center" HorizontalAlignment="Center" Width="10" Height="10"/>
  219.                                 <Path x:Name="CheckMark1" Stroke="{DynamicResource PrimaryForegroundActive}" StrokeThickness="2" SnapsToDevicePixels="False" Data="M1,14 L14,1" Margin="0" Stretch="Fill" VerticalAlignment="Center" HorizontalAlignment="Center" Width="10" Height="10"/>
  220.                             </Grid>
  221.                         </BulletDecorator.Bullet>
  222.                         <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" Margin="5,0,0,0"/>
  223.                     </BulletDecorator>
  224.  
  225.                     <!-- This uses Visibility to hide and show the CheckMark on IsChecked -->
  226.                     <ControlTemplate.Triggers>
  227.                         <Trigger Property="IsChecked" Value="false">
  228.                             <Setter Property="Visibility" Value="Collapsed" TargetName="CheckMark" />
  229.                             <Setter Property="Visibility" Value="Collapsed" TargetName="CheckMark1" />
  230.                         </Trigger>
  231.                     </ControlTemplate.Triggers>
  232.  
  233.                 </ControlTemplate>
  234.             </Setter.Value>
  235.         </Setter>
  236.     </Style>
  237.  
  238. </ResourceDictionary>
  239.  
Advertisement
Add Comment
Please, Sign In to add comment