<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
                    xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
                    xmlns:local="clr-namespace:Gallery">

  <FontFamily x:Key="IconFont">Arial</FontFamily>

  <SolidColorBrush x:Key="NoesisLogoFg" Color="#07000000"/>
  <SolidColorBrush x:Key="NoesisLogoBlueBg" Color="#FF2AA6E2"/>
  <LinearGradientBrush x:Key="MainWindowBackground" StartPoint="0.5,0" EndPoint="0.5,1">
    <GradientStop Offset="0" Color="#FF184C79"/>
    <GradientStop Offset="0.05" Color="#FF1B5688"/>
    <GradientStop Offset="1" Color="#FF123859"/>
  </LinearGradientBrush>
  <LinearGradientBrush x:Key="LR_Shadow" EndPoint="1,0.5" StartPoint="0,0.5">
    <GradientStop Color="#3F000000" Offset="0"/>
    <GradientStop Color="#00000000" Offset="1"/>
  </LinearGradientBrush>

  <Geometry x:Key="NoesisLogoGeometry">M64.552314,61.408115 L90.473059,64.639252 65.938536,97.224111 96.858771,170.22477 151.36087,176.44062 176.65871,144.70187 186.30899,167.69955 161.59547,200.607 80.812194,191.57223 39.827483,94.941438 z M48.254649,23.461594 L152.39867,36.273918 169.09616,74.476677 153.32091,95.305482 137.28592,57.748096 58.689337,48.038651 58.673125,48.036747 26.085236,92.157874 40.901858,129.9017 16.161385,126.74894 0.032970434,88.96424 z M136.8885,0 L177.71051,4.9764633 210.32399,79.460176 147.07187,163.27949 105.70369,158.62394 95.540381,134.55325 136.09376,139.68585 183.81151,76.187043 161.88087,25.886173 121.79224,19.86055 z</Geometry>
  <Geometry x:Key="NoesisTextGeometry">M92.8579999677658,70.3415300000004L91.6092999677657,70.3415300000004C89.1117999677657,70.3415300000004 86.3690999677657,69.0553500000004 84.6772999677657,67.5409700000003 83.3359999677656,66.3402600000004 81.3786999677656,63.7640900000003 79.5695999677656,61.6829800000004L48.2047999677656,14.2132800000004C44.6023999677656,9.61943000000042 40.5841999677656,5.85798000000045 37.5730999677657,3.3297700000004 32.8352999677656,1.39255000000037 29.1355999677657,0.416200000000344 22.8921999677656,0.416200000000344L-3.22343520764434E-08,0.416200000000344 -3.22343520764434E-08,91.5688500000003 21.6435999677657,91.5688500000003 21.6435999677657,21.6435500000003 22.8921999677656,21.6435500000003C25.3893999677656,21.6435500000003 27.0235999677656,22.4759800000004 29.1048999677656,23.7246500000003 31.1705999677658,25.5488600000003 33.1231999677656,27.6454000000003 34.6437999677657,30.1582000000003L66.0398999677656,78.0749800000003C69.6422999677656,82.7973200000003 72.2215999677657,85.6954300000003 75.5205999677657,88.6398700000003 80.0990999677657,90.7209900000004 84.9497999677657,91.9850800000002 91.6092999677657,91.9850800000002L114.501399967766,91.9850800000002 114.501399967766,2.27373673749166E-13 92.8579999677658,2.27373673749166E-13z M206.253499967766,3.41060514011881E-13L160.667099967766,3.41060514011881E-13C137.774799967766,3.41060514011881E-13,126.120799967766,9.57309000000032,126.120799967766,29.1355300000003L126.120799967766,62.4333200000003C126.120799967766,81.5795200000003,137.774799967766,91.5688500000003,160.667099967766,91.5688500000003L206.253499967766,91.5688500000003C229.145899967766,91.5688500000003,240.800099967766,81.9957600000003,240.800099967766,62.4333200000003L240.800099967766,29.1355300000003C240.800099967766,9.98931000000039,229.145899967766,3.41060514011881E-13,206.253499967766,3.41060514011881E-13z M218.323899967766,62.4333200000003C218.323899967766,67.4279700000003,214.161899967766,70.3415300000004,206.253499967766,70.3415300000004L160.667099967766,70.3415300000004C152.758899967766,70.3415300000004,148.596999967766,67.8441800000004,148.596999967766,62.4333200000003L148.596999967766,29.1355300000003C148.596999967766,23.7246500000003,152.758899967766,21.2273400000003,160.667099967766,21.2273400000003L206.253499967766,21.2273400000003C214.161899967766,21.2273400000003,218.323899967766,23.7246500000003,218.323899967766,29.1355300000003z M274.513899967766,65.7631100000002L274.513899967766,56.6062200000003 366.277899967766,56.6062200000003 366.277899967766,35.3788800000003 274.513899967766,35.3788800000003 274.513899967766,26.2219700000003C274.513899967766,23.3084200000003,276.178999967766,21.6435500000002,279.508699967766,21.6435500000002L366.694299967766,21.6435500000002 366.694299967766,2.27373673749166E-13 279.508699967766,2.27373673749166E-13C261.194999967766,2.27373673749166E-13,252.037899967766,7.49200000000019,252.037899967766,22.0597700000002L252.037899967766,68.6766500000002C252.037899967766,83.6606500000002,261.194999967766,91.1526500000002,279.508699967766,91.1526500000002L367.110299967766,91.1526500000002 367.110299967766,69.9253100000002 279.508699967766,69.9253100000002C276.178999967766,70.3415300000001,274.513899967766,68.6766500000002,274.513899967766,65.7631100000002z M464.725099967766,34.9626400000003L404.986699967766,34.9626400000003C401.656899967766,34.9626400000003,399.575899967766,33.7139800000003,399.575899967766,31.6328800000003L399.575899967766,24.5570900000003C399.575899967766,22.4759800000004,401.240899967766,21.2273400000003,404.986699967766,21.2273400000003L489.281899967766,21.2273400000003 489.281899967766,3.41060514011881E-13 404.986699967766,3.41060514011881E-13C386.672899967766,3.41060514011881E-13,377.516099967766,7.4920000000003,377.516099967766,22.0597700000003L377.516099967766,36.6275400000003C377.516099967766,49.5304200000003,386.672899967766,56.1899800000003,404.986699967766,56.1899800000003L464.725099967766,56.1899800000003C468.054699967766,56.1899800000003,469.719799967766,57.4386300000003,469.719799967766,59.5197500000004L469.719799967766,67.0117400000004C469.719799967766,69.0928600000004,468.054699967766,70.3415300000004,464.725099967766,70.3415300000004L380.429599967766,70.3415300000004 380.429599967766,91.5688500000003 464.725099967766,91.5688500000003C483.038799967766,91.5688500000003,492.195599967766,84.0768600000003,492.195599967766,69.5090700000003L492.195599967766,57.0224100000002C492.195599967766,42.4546400000002,483.038799967766,34.9626400000003,464.725099967766,34.9626400000003z M503.433699967766,3.41060514011881E-13L525.909499967766,3.41060514011881E-13 525.909499967766,91.1526500000003 503.433699967766,91.1526500000003z M625.010299967766,34.9626400000003L565.054499967766,34.9626400000003C561.724799967766,34.9626400000003,559.643599967766,33.7139800000003,559.643599967766,31.6328800000003L559.643599967766,24.5570900000003C559.643599967766,22.4759800000004,561.308399967766,21.2273400000003,565.054499967766,21.2273400000003L649.567499967766,21.2273400000003 649.567499967766,3.41060514011881E-13 565.054499967766,3.41060514011881E-13C546.740699967766,3.41060514011881E-13,537.583799967766,7.4920000000003,537.583799967766,22.0597700000003L537.583799967766,36.6275400000003C537.583799967766,49.5304200000003,546.740699967766,56.1899800000003,565.054499967766,56.1899800000003L625.010299967766,56.1899800000003C628.340199967766,56.1899800000003,630.005099967766,57.4386300000003,630.005099967766,59.5197500000004L630.005099967766,67.0117400000004C630.005099967766,69.0928600000004,628.340199967766,70.3415300000004,625.010299967766,70.3415300000004L540.497399967766,70.3415300000004 540.497399967766,91.5688500000003 625.010299967766,91.5688500000003C643.324099967766,91.5688500000003,652.481199967766,84.0768600000003,652.481199967766,69.5090700000003L652.481199967766,57.0224100000002C652.064899967766,42.4546400000002,642.907899967766,34.9626400000003,625.010299967766,34.9626400000003z</Geometry>
  <Geometry x:Key="NoesisGuiTextGeometry">M218.200700106049,67.01174C218.200700106049,69.09286,216.535800106049,70.34153,213.205900106049,70.34153L153.648800106049,70.34153C150.319100106049,70.34153,148.237800106049,69.09286,148.237800106049,67.01174L148.237800106049,0.416200000000003 125.762100106049,0.416200000000003 125.762100106049,69.50907C125.762100106049,84.49309,134.918800106049,91.98508,153.232600106049,91.98508L212.789900106049,91.98508C231.103500106049,91.98508,240.260500106049,84.49309,240.260500106049,69.92531L240.260500106049,2.5410988417629E-21 217.784500106049,2.5410988417629E-21 217.784500106049,67.01174z M251.914700106049,2.5410988417629E-21L274.390700106049,2.5410988417629E-21 274.390700106049,91.15265 251.914700106049,91.15265z M64.3942001060486,35.79507L64.3942001060486,58.27109 92.2812001060488,58.27109 92.2812001060488,70.34153 27.4707001060488,70.34153C24.1410001060485,70.34153,22.0598001060485,68.67665,22.0598001060485,65.76311L22.0598001060485,25.80576C22.0598001060485,22.89222,23.7246001060485,21.2273399999999,27.4707001060488,21.2273399999999L112.259700106049,21.2273399999999 112.259700106049,2.5410988417629E-21 27.4707001060488,2.5410988417629E-21C9.15670010604844,2.5410988417629E-21,1.06048446468776E-07,7.49199999999996,1.06048446468776E-07,22.05977L1.06048446468776E-07,68.67665C1.06048446468776E-07,83.66065,9.15670010604844,91.15265,27.4707001060488,91.15265L114.757000106049,91.15265 114.757000106049,35.37888 64.3942001060486,35.37888z</Geometry>
  <Geometry x:Key="SelectorExpandGeometry">M0,2L10,2M0,5L10,5M0,8L10,8</Geometry>

  <ControlTemplate x:Key="SelectorExpanderButtonTemplate" TargetType="{x:Type ToggleButton}">
    <Border x:Name="Border" Background="{DynamicResource Brush.Window.Background}">
      <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Background" Value="{DynamicResource Brush.Header.Over}" TargetName="Border"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <!-- Theme Selector -->
  <Style x:Key="ColorSelectorToggleStyle" TargetType="{x:Type ToggleButton}">
    <Setter Property="OverridesDefaultStyle" Value="True" />
    <Setter Property="Foreground" Value="{DynamicResource Brush.Foreground.Normal}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type ToggleButton}">
          <ContentPresenter />
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  <ControlTemplate x:Key="ColorSelectorComboBoxTemplate" TargetType="{x:Type ComboBox}">
    <Grid>
      <ToggleButton x:Name="DropDownButton" Style="{StaticResource ColorSelectorToggleStyle}" Foreground="{TemplateBinding Foreground}" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" IsTabStop="False">
        <Grid>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
          </Grid.ColumnDefinitions>
          <Border x:Name="Border" Grid.ColumnSpan="2" CornerRadius="20" RenderTransformOrigin="1,0">
            <Border.Background>
              <SolidColorBrush Color="{StaticResource Color.Gray9}" Opacity="0"/>
            </Border.Background>
            <Border.RenderTransform>
              <ScaleTransform ScaleX="0"/>
            </Border.RenderTransform>
          </Border>
          <Ellipse Grid.ColumnSpan="2" Width="32" Height="40" HorizontalAlignment="Right" Fill="Transparent"/>
          <StackPanel x:Name="SelectionBox" Grid.Column="0" Margin="2,0" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
            <StackPanel.RenderTransform>
              <TranslateTransform X="110"/>
            </StackPanel.RenderTransform>
            <Ellipse Width="24" Height="24" Stroke="{StaticResource Brush.Window.Background}" StrokeThickness="1.1" noesis:Element.PPAAOut="1">
              <Ellipse.Fill>
                <SolidColorBrush Color="{Binding SelectedItem.Color, RelativeSource={RelativeSource TemplatedParent}}"/>
              </Ellipse.Fill>
            </Ellipse>
            <TextBlock x:Name="SelectionText" Text="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" Margin="12,0,0,0" Width="0"/>
          </StackPanel>
          <Path x:Name="Arrow" Grid.Column="1" Data="{StaticResource Geometry.ComboBox.Arrow}" VerticalAlignment="Center" Margin="10,1,10,0" IsHitTestVisible="False">
            <Path.RenderTransform>
              <TranslateTransform />
            </Path.RenderTransform>
            <Path.Stroke>
              <SolidColorBrush Color="{StaticResource Color.Black}" Opacity="0"/>
            </Path.Stroke>
          </Path>
        </Grid>
      </ToggleButton>
      <Popup x:Name="PART_Popup" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" Focusable="False" PopupAnimation="Slide" Placement="Bottom" AllowsTransparency="True" VerticalOffset="4">
        <Border x:Name="DropDownBorder" Background="{DynamicResource Brush.Background.Popup}" BorderBrush="{DynamicResource Brush.Border.Popup}" BorderThickness="1" CornerRadius="6" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
          <ScrollViewer Focusable="False" Padding="0,6" KeyboardNavigation.TabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Contained">
            <ItemsPresenter/>
          </ScrollViewer>
        </Border>
      </Popup>
    </Grid>
    <ControlTemplate.Resources>
      <Storyboard x:Key="Anim.HoverOn">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Opacity)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
            <EasingDoubleKeyFrame.EasingFunction>
              <CircleEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SelectionBox" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="6">
            <EasingDoubleKeyFrame.EasingFunction>
              <CircleEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SelectionText" Storyboard.TargetProperty="(FrameworkElement.Width)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="60">
            <EasingDoubleKeyFrame.EasingFunction>
              <CircleEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
          <EasingDoubleKeyFrame KeyTime="0:0:0" Value="-8"/>
          <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="-8"/>
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
            <EasingDoubleKeyFrame.EasingFunction>
              <CircleEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Opacity)">
          <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
          <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0"/>
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
            <EasingDoubleKeyFrame.EasingFunction>
              <CircleEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
      <Storyboard x:Key="Anim.HoverOff">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Opacity)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
            <EasingDoubleKeyFrame.EasingFunction>
              <CircleEase EasingMode="EaseIn"/>
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SelectionBox" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="110">
            <EasingDoubleKeyFrame.EasingFunction>
              <CircleEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="SelectionText" Storyboard.TargetProperty="(FrameworkElement.Width)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0">
            <EasingDoubleKeyFrame.EasingFunction>
              <CircleEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Opacity)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="0">
            <EasingDoubleKeyFrame.EasingFunction>
              <CircleEase EasingMode="EaseOut"/>
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
      <Storyboard x:Key="Anim.Expand">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)">
          <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="2" />
          <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
            <EasingDoubleKeyFrame.EasingFunction>
              <CubicEase EasingMode="EaseOut" />
            </EasingDoubleKeyFrame.EasingFunction>
          </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
    </ControlTemplate.Resources>
    <ControlTemplate.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Trigger.EnterActions>
          <BeginStoryboard Storyboard="{StaticResource Anim.HoverOn}"/>
        </Trigger.EnterActions>
        <Trigger.ExitActions>
          <BeginStoryboard Storyboard="{StaticResource Anim.HoverOff}"/>
        </Trigger.ExitActions>
      </Trigger>
      <Trigger Property="IsDropDownOpen" Value="True">
        <Trigger.EnterActions>
          <BeginStoryboard Storyboard="{StaticResource Anim.Expand}" />
        </Trigger.EnterActions>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="ColorSelectorComboBoxStyle" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}">
    <Setter Property="Template" Value="{StaticResource ColorSelectorComboBoxTemplate}"/>
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  </Style>
  <Style x:Key="ColorSelectorComboBoxItemStyle" TargetType="{x:Type ComboBoxItem}" BasedOn="{StaticResource {x:Type ComboBoxItem}}">
    <Setter Property="Padding" Value="8,7"/>
  </Style>
  <DataTemplate x:Key="ColorItemTemplate">
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="24"/>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <Ellipse Width="24" Height="24" Stroke="{StaticResource Brush.Window.Background}" StrokeThickness="1.1" noesis:Element.PPAAOut="1">
        <Ellipse.Fill>
          <SolidColorBrush Color="{Binding Color}"/>
        </Ellipse.Fill>
      </Ellipse>
      <TextBlock Grid.Column="1" Text="{Binding Name}" VerticalAlignment="Center" Margin="12,0,0,0"/>
    </Grid>
  </DataTemplate>

  <!-- Sample TreeView Selector -->
  <ControlTemplate x:Key="SampleSelectorItemTemplate" TargetType="TreeViewItem">
    <ControlTemplate.Resources>
      <Storyboard x:Key="Anim.Expand">
        <DoubleAnimation Storyboard.TargetName="Arrow" Storyboard.TargetProperty="RenderTransform.Angle" To="90" Duration="0:0:0.15"/>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemsBorder" Storyboard.TargetProperty="Visibility">
          <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
        </ObjectAnimationUsingKeyFrames>
        <DoubleAnimation Storyboard.TargetName="ItemsHost" Storyboard.TargetProperty="RenderTransform.ScaleY" To="1" Duration="0:0:0.2">
          <DoubleAnimation.EasingFunction>
            <BackEase EasingMode="EaseOut" Amplitude="0.2"/>
          </DoubleAnimation.EasingFunction>
        </DoubleAnimation>
      </Storyboard>
      <Storyboard x:Key="Anim.Collapse">
        <DoubleAnimation Storyboard.TargetName="Arrow" Storyboard.TargetProperty="RenderTransform.Angle" To="0" Duration="0:0:0.2"/>
        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemsBorder" Storyboard.TargetProperty="Visibility">
          <DiscreteObjectKeyFrame KeyTime="0:0:0.2" Value="{x:Static Visibility.Collapsed}"/>
        </ObjectAnimationUsingKeyFrames>
        <DoubleAnimation Storyboard.TargetName="ItemsHost" Storyboard.TargetProperty="RenderTransform.ScaleY" To="0" Duration="0:0:0.2" AccelerationRatio="0.5"/>
      </Storyboard>
    </ControlTemplate.Resources>
    <Grid x:Name="Root">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <Border x:Name="Border" Grid.Row="0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
        <ToggleButton x:Name="ExpandButton" Style="{StaticResource Style.TreeViewItem.Toggle}" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" IsTabStop="False">
          <StackPanel Orientation="Horizontal">
            <Decorator Width="{Binding Tag, RelativeSource={RelativeSource AncestorType={x:Type ItemsPresenter}, AncestorLevel=1}}"/>
            <Path x:Name="Arrow" Data="{StaticResource Geometry.TreeViewItem.Arrow}" Stroke="{DynamicResource Brush.TreeView.Collapsed}" HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False" RenderTransformOrigin="0.5,0.5">
              <Path.RenderTransform>
                <RotateTransform />
              </Path.RenderTransform>
            </Path>
            <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}"/>
          </StackPanel>
        </ToggleButton>
      </Border>
      <Decorator x:Name="ItemsBorder" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Visibility="Collapsed">
        <ItemsPresenter x:Name="ItemsHost" Tag="32" RenderTransformOrigin="0.5,0">
          <ItemsPresenter.RenderTransform>
            <ScaleTransform ScaleY="0"/>
          </ItemsPresenter.RenderTransform>
        </ItemsPresenter>
      </Decorator>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="HasItems" Value="False">
        <Setter Property="IsEnabled" Value="False" TargetName="ExpandButton"/>
        <Setter Property="Visibility" Value="Collapsed" TargetName="Arrow"/>
      </Trigger>
      <Trigger Property="IsExpanded" Value="True">
        <Setter Property="Background" Value="{DynamicResource Brush.Header.Normal}" TargetName="Border"/>
        <Setter Property="Stroke" Value="{DynamicResource Brush.Glyph.Over}" TargetName="Arrow"/>
        <Trigger.EnterActions>
          <BeginStoryboard Storyboard="{StaticResource Anim.Expand}"/>
        </Trigger.EnterActions>
        <Trigger.ExitActions>
          <BeginStoryboard Storyboard="{StaticResource Anim.Collapse}"/>
        </Trigger.ExitActions>
      </Trigger>
      <Trigger Property="IsMouseOver" Value="True" SourceName="Border">
        <Setter Property="Background" Value="{DynamicResource Brush.Item.Over}" TargetName="Border"/>
        <Setter Property="Stroke" Value="{DynamicResource Brush.Glyph.Over}" TargetName="Arrow"/>
      </Trigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsSelected" Value="True"/>
          <Condition Property="HasItems" Value="False"/>
        </MultiTrigger.Conditions>
        <Setter Property="Background" Value="{DynamicResource Brush.Item.Selected}" TargetName="Border"/>
      </MultiTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Foreground" Value="{DynamicResource Brush.Foreground.Disabled}"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="SampleSelectorItemStyle" TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type HeaderedItemsControl}}">
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Setter Property="Foreground" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type TreeView}}}"/>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Padding" Value="12,7"/>
    <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type TreeView}}}"/>
    <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type TreeView}}}"/>
    <Setter Property="Template" Value="{StaticResource SampleSelectorItemTemplate}"/>
  </Style>
  <DataTemplate x:Key="SampleTemplate">
    <StackPanel Orientation="Horizontal">
      <TextBlock x:Name="icon" Text="{Binding Icon, FallbackValue=A}" FontFamily="{StaticResource IconFont}" FontSize="14.68" Margin="0,-5,10,-5" Foreground="{DynamicResource Brush.Foreground.Placeholder}" VerticalAlignment="Center"/>
      <TextBlock Text="{Binding Name, FallbackValue=Animations}"/>
    </StackPanel>
    <DataTemplate.Triggers>
      <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type TreeViewItem}}}" Value="True">
        <Setter Property="Foreground" Value="{DynamicResource Brush.Foreground.Normal}" TargetName="icon"/>
      </DataTrigger>
    </DataTemplate.Triggers>
  </DataTemplate>
  <HierarchicalDataTemplate x:Key="SampleCategoryTemplate" ItemsSource="{Binding Samples}" ItemTemplate="{StaticResource SampleTemplate}">
    <TextBlock Text="{Binding Name}"/>
  </HierarchicalDataTemplate>

  <!-- Sample Control -->
  <SolidColorBrush x:Key="TitleBrush" Color="White"/>
  <SolidColorBrush x:Key="DescBrush" Color="LightGray"/>
  <SolidColorBrush x:Key="LinkNormalBrush" Color="#FF1098DF"/>
  <SolidColorBrush x:Key="LinkOverBrush" Color="#E4E6E8"/>

  <ControlTemplate x:Key="ExternalLinkControl" TargetType="Control">
    <ControlTemplate.Resources>
      <Geometry x:Key="IconGeometry">M2,8L10,0M7,0L10,0 10,3M5,0L0,0 0,10 10,10 10,5</Geometry>
    </ControlTemplate.Resources>
    <Border Background="Transparent" Padding="2">
      <b:Interaction.Triggers>
        <b:EventTrigger EventName="MouseLeftButtonDown">
          <b:LaunchUriOrFileAction Path="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"/>
        </b:EventTrigger>
      </b:Interaction.Triggers>
      <Path x:Name="Icon" Data="{StaticResource IconGeometry}" Stroke="{StaticResource LinkNormalBrush}"/>
    </Border>
    <ControlTemplate.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter TargetName="Icon" Property="Stroke" Value="{StaticResource LinkOverBrush}"/>
      </Trigger>
      <Trigger Property="IsEnabled" Value="True">
        <Setter Property="Cursor" Value="Hand"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="ExternalLinkStyle" TargetType="Control">
    <Setter Property="ToolTip" Value="Go to documentation"/>
    <Setter Property="Template" Value="{StaticResource ExternalLinkControl}"/>
  </Style>

  <ControlTemplate x:Key="SampleControlTemplate" TargetType="HeaderedContentControl">
    <Grid x:Name="Root">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>

      <Grid Grid.RowSpan="2">
        <Grid.RowDefinitions>
          <RowDefinition Height="0.5*"/>
          <RowDefinition Height="9.5*"/>
        </Grid.RowDefinitions>
        <FrameworkElement x:Name="TitleSize" Grid.Row="0"/>
      </Grid>
      <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,8,0,0">
        <ContentPresenter ContentSource="Header" TextElement.FontWeight="Bold" TextElement.Foreground="White" TextElement.FontSize="24"/>
        <Control Style="{StaticResource ExternalLinkStyle}" Margin="10,5,0,0" VerticalAlignment="Center" Tag="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"/>
      </StackPanel>
      <Grid Grid.Row="1" VerticalAlignment="Top" Margin="0,10,0,0">
        <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" PanningMode="VerticalOnly">
          <ContentPresenter ContentSource="Content" Margin="30,0,30,20"/>
        </ScrollViewer>
      </Grid>
    </Grid>
  </ControlTemplate>
  <Style x:Key="SampleControlStyle" TargetType="HeaderedContentControl" BasedOn="{StaticResource {x:Type HeaderedContentControl}}">
    <Setter Property="FontFamily" Value="{StaticResource Font.Family.Default}"/>
    <Setter Property="FontSize" Value="{StaticResource Font.Size.Normal}"/>
    <Setter Property="Template" Value="{StaticResource SampleControlTemplate}"/>
  </Style>

  <!-- Sample Section -->
  <Style x:Key="SampleSectionTitle" TargetType="TextBlock">
    <Setter Property="FontWeight" Value="Bold"/>
    <Setter Property="FontSize" Value="17"/>
    <Setter Property="Foreground" Value="{StaticResource TitleBrush}"/>
  </Style>
  <Style x:Key="SampleSectionDesc" TargetType="TextBlock">
    <Setter Property="TextWrapping" Value="Wrap"/>
    <Setter Property="FontSize" Value="15"/>
    <Setter Property="Foreground" Value="{StaticResource DescBrush}"/>
  </Style>

  <ControlTemplate x:Key="SampleSectionTemplate" TargetType="HeaderedContentControl">
    <StackPanel x:Name="Root">
      <StackPanel.Resources>
        <Storyboard x:Key="LoadAnim">
          <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="RenderTransform.X">
            <EasingDoubleKeyFrame KeyTime="0" Value="50"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0">
              <EasingDoubleKeyFrame.EasingFunction>
                <CircleEase EasingMode="EaseOut"/>
              </EasingDoubleKeyFrame.EasingFunction>
            </EasingDoubleKeyFrame>
          </DoubleAnimationUsingKeyFrames>
        </Storyboard>
      </StackPanel.Resources>
      <b:Interaction.Triggers>
        <b:TimerTrigger EventName="Loaded" TotalTicks="1" MillisecondsPerTick="{Binding TabIndex, RelativeSource={RelativeSource TemplatedParent}}">
          <b:ControlStoryboardAction Storyboard="{StaticResource LoadAnim}"/>
        </b:TimerTrigger>
      </b:Interaction.Triggers>
      <StackPanel.RenderTransform>
        <TranslateTransform X="50"/>
      </StackPanel.RenderTransform>
      <ContentPresenter x:Name="HeaderHost" ContentSource="Header"/>
      <Grid Margin="0,10,0,0">
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Background="{DynamicResource Brush.Background.Popup}"/>
        <TextBlock Grid.Row="0" FontSize="12" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,4,4,4">
            <Hyperlink NavigateUri="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" TextDecorations="None">Show XAML</Hyperlink>
        </TextBlock>
        <TextBlock Grid.Row="0" Text="Enable" FontSize="12" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,60,0"/>
        <ToggleButton x:Name="EnableContent" Grid.Row="0" Style="{StaticResource Style.ToggleSwitch}" HorizontalAlignment="Right" FontSize="12" IsChecked="True" FocusVisualStyle="{x:Null}" Margin="4,4,10,4" Padding="0"/>
        <Border Grid.Row="1" Margin="10">
          <Decorator x:Name="ContentWidthRef"/>
        </Border>
        <Border x:Name="ContentHost" Grid.Row="1" Background="{TemplateBinding Background}" Padding="10,20">
          <Viewbox StretchDirection="DownOnly">
            <ContentPresenter MinWidth="380" Width="{Binding ActualWidth, ElementName=ContentWidthRef}" ContentSource="Content" IsEnabled="{Binding IsChecked, ElementName=EnableContent}"/>
          </Viewbox>
        </Border>
      </Grid>
    </StackPanel>
    <ControlTemplate.Triggers>
      <Trigger Property="IsTabStop" Value="False">
        <Setter Property="Visibility" Value="Collapsed" TargetName="EnableContent"/>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>
  <Style x:Key="SampleSectionStyle" TargetType="HeaderedContentControl" BasedOn="{StaticResource {x:Type HeaderedContentControl}}">
    <Setter Property="Margin" Value="0,20,0,0"/>
    <Setter Property="Foreground" Value="{DynamicResource Brush.Foreground.Normal}" />
    <Setter Property="Background" Value="{DynamicResource Brush.Window.Background}"/>
    <Setter Property="Template" Value="{StaticResource SampleSectionTemplate}"/>
  </Style>

</ResourceDictionary>