<!--?
Copyright (c) 2012 Tim Heuer

Licensed under the Microsoft Public License (Ms-PL) (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://opensource.org/licenses/Ms-PL.html

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.-->

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Callisto.Controls"
    xmlns:primitives="using:Callisto.Controls.Primitives"
    xmlns:converters="using:Callisto.Converters">

    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Default">
            <SolidColorBrush x:Key="FlyoutBorderBrush">#FF212121</SolidColorBrush>
            <SolidColorBrush x:Key="FlyoutBackgroundBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="MenuBorderBrush">#FF212121</SolidColorBrush>
            <SolidColorBrush x:Key="MenuBackgroundBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemBaseTextBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemBaseBackgroundBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemHoverBrush">#FFDEDEDE</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemPressedBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemPressedTextBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemHoverTextBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="MenuSeparatorStrokeBrush">#FF707070</SolidColorBrush>
            <SolidColorBrush x:Key="SettingsFlyoutHeaderBackgroundBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="SettingsFlyoutContentBackgroundThemeBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="SettingsFlyoutContentForegroundThemeBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemForegroundThemeBrush">#FF5B2EC5</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemPointerOverThemeBrush">#FF8152EF</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemPointerPressedThemeBrush">#FF8152EF</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemBackgroundThemeBrush">#59FFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemDisabledForegroundThemeBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemBorderThemeBrush">Transparent</SolidColorBrush>
            <x:String x:Key="SettingsFlyoutBackButtonGlyph">&#xE0BA;</x:String>
            <SolidColorBrush x:Key="FlipViewIndicatorUnselectedThemeBrush">Gray</SolidColorBrush>
            <SolidColorBrush x:Key="FlipViewIndicatorSelectedThemeBrush">#FFFFFFFF</SolidColorBrush>
            <x:Double x:Key="CustomDialogBorderThemeThickness">0</x:Double>
            <SolidColorBrush x:Key="CustomDialogBorderThemeBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="CustomDialogBackgroundThemeBrush">#FFFFFFFF</SolidColorBrush>
        </ResourceDictionary>
        <ResourceDictionary x:Key="Light">
            <SolidColorBrush x:Key="FlyoutBorderBrush">#FF212121</SolidColorBrush>
            <SolidColorBrush x:Key="FlyoutBackgroundBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="MenuBorderBrush">#FF212121</SolidColorBrush>
            <SolidColorBrush x:Key="MenuBackgroundBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemBaseTextBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemBaseBackgroundBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemHoverBrush">#FFDEDEDE</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemPressedBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemPressedTextBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemHoverTextBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="MenuSeparatorStrokeBrush">#FF707070</SolidColorBrush>
            <SolidColorBrush x:Key="SettingsFlyoutHeaderBackgroundBrush">LightGray</SolidColorBrush>
            <SolidColorBrush x:Key="SettingsFlyoutContentBackgroundThemeBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="SettingsFlyoutContentForegroundThemeBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemForegroundThemeBrush">#FF4617B4</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemPointerOverThemeBrush">#FF7241E4</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemPointerPressedThemeBrush">#FF7241E4</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemBackgroundThemeBrush">#59000000</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemDisabledForegroundThemeBrush">#FF000000</SolidColorBrush>
            <SolidColorBrush x:Key="RatingItemBorderThemeBrush">Transparent</SolidColorBrush>
            <x:String x:Key="SettingsFlyoutBackButtonGlyph">&#xE0BA;</x:String>
            <SolidColorBrush x:Key="FlipViewIndicatorUnselectedThemeBrush">Gray</SolidColorBrush>
            <SolidColorBrush x:Key="FlipViewIndicatorSelectedThemeBrush">#FF000000</SolidColorBrush>
            <x:Double x:Key="CustomDialogBorderThemeThickness">0</x:Double>
            <SolidColorBrush x:Key="CustomDialogBorderThemeBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="CustomDialogBackgroundThemeBrush">#FF000000</SolidColorBrush>
        </ResourceDictionary>
        <ResourceDictionary x:Key="HighContrast">
            <SolidColorBrush x:Key="FlyoutBorderBrush" Color="{StaticResource SystemColorButtonTextColor}" />
            <SolidColorBrush x:Key="FlyoutBackgroundBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
            <SolidColorBrush x:Key="MenuBorderBrush" Color="{StaticResource SystemColorButtonTextColor}" />
            <SolidColorBrush x:Key="MenuBackgroundBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
            <SolidColorBrush x:Key="MenuItemBaseTextBrush" Color="{StaticResource SystemColorButtonTextColor}"/>
            <SolidColorBrush x:Key="MenuItemBaseBackgroundBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
            <SolidColorBrush x:Key="MenuItemHoverBrush" Color="{StaticResource SystemColorHighlightColor}" />
            <SolidColorBrush x:Key="MenuItemPressedBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="MenuItemPressedTextBrush" Color="{StaticResource SystemColorButtonFaceColor}"/>
            <SolidColorBrush x:Key="MenuItemHoverTextBrush" Color="{StaticResource SystemColorButtonTextColor}"/>
            <SolidColorBrush x:Key="MenuSeparatorStrokeBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="SettingsFlyoutHeaderBackgroundBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
            <SolidColorBrush x:Key="SettingsFlyoutContentBackgroundThemeBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
            <SolidColorBrush x:Key="SettingsFlyoutContentForegroundThemeBrush" Color="{StaticResource SystemColorButtonTextColor}" />
            <SolidColorBrush x:Key="RatingItemForegroundThemeBrush" Color="{StaticResource SystemColorHighlightColor}" />
            <SolidColorBrush x:Key="RatingItemPointerOverThemeBrush" Color="{StaticResource SystemColorButtonTextColor}" />
            <SolidColorBrush x:Key="RatingItemPointerPressedThemeBrush" Color="{StaticResource SystemColorButtonTextColor}" />
            <SolidColorBrush x:Key="RatingItemBackgroundThemeBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
            <SolidColorBrush x:Key="RatingItemDisabledForegroundThemeBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
            <SolidColorBrush x:Key="RatingItemBorderThemeBrush" Color="{StaticResource SystemColorButtonTextColor}" />
            <x:String x:Key="SettingsFlyoutBackButtonGlyph">&#xE0C4;</x:String>
            <SolidColorBrush x:Key="FlipViewIndicatorUnselectedThemeBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
            <SolidColorBrush x:Key="FlipViewIndicatorSelectedThemeBrush" Color="{StaticResource SystemColorHighlightColor}" />
            <x:Double x:Key="CustomDialogBorderThemeThickness">1</x:Double>
            <SolidColorBrush x:Key="CustomDialogBorderThemeBrush">#FFFFFFFF</SolidColorBrush>
            <SolidColorBrush x:Key="CustomDialogBackgroundThemeBrush" Color="{StaticResource SystemColorButtonFaceColor}" />
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>

    <converters:BrushToColorConverter x:Key="BrushToColor" />
    <converters:ColorBrightnessConverter x:Key="ColorBrightness" />
    <converters:ColorContrastConverter x:Key="ColorContrast" />
    <x:String x:Key="SettingsFlyoutHeaderTextDefault">Application Setting</x:String>

    <Style x:Key="ToggleMenuItemCheckBox" TargetType="CheckBox">
        <Setter Property="MinHeight" Value="42" />
        <!-- setting this because not having it will give the CheckBox 50 MinHeight-->
        <Setter Property="Padding" Value="2,10,20,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CheckBox">
                    <Border x:Name="RootBorder" Background="{TemplateBinding Background}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="PointerOver"/>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="CheckGlyph">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource CheckBoxPressedForegroundThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder"
                                                                       Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemPressedBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemPressedTextBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="CheckGlyph">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource CheckBoxDisabledForegroundThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource CheckBoxContentDisabledForegroundThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CheckStates">
                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="CheckGlyph"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unchecked"/>
                                <VisualState x:Name="Indeterminate"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused"/>
                                <VisualState x:Name="Unfocused"/>
                                <VisualState x:Name="PointerFocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="25"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Path x:Name="CheckGlyph" Data="F1 M 0,58 L 2,56 L 6,60 L 13,51 L 15,53 L 6,64 z" Fill="{StaticResource CheckBoxForegroundThemeBrush}" FlowDirection="LeftToRight" Height="14" Opacity="0" Stretch="Fill" Width="16"/>
                            <ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" Grid.Column="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- NOTE: SettingsBackButtonStyle is deprecated but kept here in the event an app relies on it -->
    <!-- SettingsBackButtonStyle2 is created and set as a Grid resource where it is needed in the SettingsFlyout template definition -->
    <Style x:Key="SettingsBackButtonStyle" TargetType="Button">
        <Setter Property="MinWidth" Value="0"/>
        <Setter Property="FontFamily" Value="Segoe UI Symbol"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="FontSize" Value="26.66667"/>
        <Setter Property="AutomationProperties.AutomationId" Value="BackButton"/>
        <Setter Property="AutomationProperties.Name" Value="Back"/>
        <Setter Property="AutomationProperties.ItemType" Value="Navigation Button"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid x:Name="RootGrid" Width="30" Height="30">
                        <Grid Margin="-3,-5,0,0">
                            <TextBlock x:Name="BackgroundGlyph" Text="&#xE0D4;" Foreground="{StaticResource BackButtonBackgroundThemeBrush}"/>
                            <TextBlock x:Name="NormalGlyph" Text="{StaticResource SettingsFlyoutBackButtonGlyph}" Foreground="{StaticResource BackButtonForegroundThemeBrush}"/>
                            <TextBlock x:Name="ArrowGlyph" Text="&#xE0C4;" Foreground="{StaticResource BackButtonPressedForegroundThemeBrush}" Opacity="0"/>
                        </Grid>
                        <Rectangle
                            x:Name="FocusVisualWhite"
                            IsHitTestVisible="False"
                            Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
                            StrokeEndLineCap="Square"
                            StrokeDashArray="1,1"
                            Opacity="0"
                            StrokeDashOffset="1.5"/>
                        <Rectangle
                            x:Name="FocusVisualBlack"
                            IsHitTestVisible="False"
                            Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
                            StrokeEndLineCap="Square"
                            StrokeDashArray="1,1"
                            Opacity="0"
                            StrokeDashOffset="0.5"/>

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonPointerOverBackgroundThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NormalGlyph" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonPointerOverForegroundThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonForegroundThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <DoubleAnimation
                                            Storyboard.TargetName="ArrowGlyph"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0"/>
                                        <DoubleAnimation
                                            Storyboard.TargetName="NormalGlyph"
                                            Storyboard.TargetProperty="Opacity"
                                            To="0"
                                            Duration="0"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="FocusVisualWhite"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0"/>
                                        <DoubleAnimation
                                            Storyboard.TargetName="FocusVisualBlack"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                                <VisualState x:Name="PointerFocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:Menu">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:Menu">
                    <ItemsControl x:Name="ItemList" TabNavigation="Cycle" Margin="0,5,0,5" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:MenuItem">
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="MenuTextMargin" Value="20,10,20,12" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:MenuItem">
                    <Border x:Name="RootBorder"
                            Background="{StaticResource MenuBackgroundBrush}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Base">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemBaseBackgroundBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuText"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemBaseTextBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder"
                                                                       Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemPressedBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuText"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemPressedTextBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Hover">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemHoverBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuText"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemHoverTextBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder"
                                                                       Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonDisabledBackgroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonDisabledBorderThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuText"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonDisabledForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <TextBlock x:Name="MenuText" Text="{TemplateBinding Text}" Margin="{TemplateBinding MenuTextMargin}" VerticalAlignment="Center" TextTrimming="WordEllipsis" 
                                       FontFamily="{StaticResource ContentControlThemeFontFamily}" FontSize="{StaticResource ControlContentThemeFontSize}" Foreground="{StaticResource MenuItemBaseTextBrush}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:ToggleMenuItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ToggleMenuItem">
                    <Border x:Name="RootBorder"
                            Background="{StaticResource MenuBackgroundBrush}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Base">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemBaseBackgroundBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuText"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemBaseTextBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder"
                                                                       Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemPressedBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuText"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemPressedTextBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Hover">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder" Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemHoverBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuText"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MenuItemHoverTextBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder"
                                                                       Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonDisabledBackgroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootBorder"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonDisabledBorderThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MenuText"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonDisabledForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <CheckBox x:Name="MenuText" Style="{StaticResource ToggleMenuItemCheckBox}" Content="{TemplateBinding Text}" 
                                  FontFamily="{StaticResource ContentControlThemeFontFamily}" FontSize="{StaticResource ControlContentThemeFontSize}" 
                                  Foreground="{StaticResource MenuItemBaseTextBrush}" IsChecked="{TemplateBinding IsChecked}" IsTabStop="False"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:MenuItemSeparator">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:MenuItemSeparator">
                    <Border BorderThickness=".25" BorderBrush="{StaticResource MenuSeparatorStrokeBrush}" 
                            HorizontalAlignment="Stretch" Margin="20,9,20,10" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:Flyout">
        <Setter Property="Background" Value="{StaticResource FlyoutBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource FlyoutBorderBrush}" />
        <Setter Property="HostMargin" Value="0,12,0,12" />
        <Setter Property="MinHeight" Value="54" />
        <Setter Property="MinWidth" Value="70" />
        <Setter Property="MaxHeight" Value="758" />
        <Setter Property="MaxWidth" Value="510" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:Flyout">
                    <Border
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="2" Margin="{TemplateBinding HostMargin}">
                        <ContentPresenter Content="{TemplateBinding Content}" Margin="{TemplateBinding Margin}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:SettingsFlyout">
        <Setter Property="Background" Value="{StaticResource ApplicationPageBackgroundThemeBrush}" />
        <Setter Property="HeaderBrush" Value="{StaticResource SettingsFlyoutHeaderBackgroundBrush}" />
        <Setter Property="HeaderText" Value="{StaticResource SettingsFlyoutHeaderTextDefault}" />
        <Setter Property="ContentBackgroundBrush" Value="{StaticResource SettingsFlyoutContentBackgroundThemeBrush}" />
        <Setter Property="ContentForegroundBrush" Value="{StaticResource SettingsFlyoutContentForegroundThemeBrush}" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="MaxWidth" Value="646" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:SettingsFlyout">
                    <Border x:Name="PART_RootBorder" BorderBrush="{Binding ElementName=PART_HeaderGrid, Path=Background, RelativeSource={RelativeSource Mode=Self}, Converter={StaticResource ColorBrightness}, ConverterParameter=0.8}" BorderThickness="1,0,0,0" VerticalAlignment="Stretch">
                        <Grid Background="{TemplateBinding Background}" VerticalAlignment="Stretch">
                            <!-- Root grid definition -->
                            <Grid.RowDefinitions>
                                <RowDefinition Height="80" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>

                            <!-- Header area for panel -->
                            <Grid Background="{TemplateBinding HeaderBrush}" Grid.Row="0" x:Name="PART_HeaderGrid">

                                <Grid Margin="40,35,40,13">
                                    <Grid.Resources>
                                        <Style x:Key="SettingsBackButtonStyle2" TargetType="Button">
                                            <Setter Property="MinWidth" Value="0"/>
                                            <Setter Property="FontFamily" Value="Segoe UI Symbol"/>
                                            <Setter Property="FontWeight" Value="Normal"/>
                                            <Setter Property="FontSize" Value="26.66667"/>
                                            <Setter Property="AutomationProperties.AutomationId" Value="BackButton"/>
                                            <Setter Property="AutomationProperties.Name" Value="Back"/>
                                            <Setter Property="AutomationProperties.ItemType" Value="Navigation Button"/>
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="Button">
                                                        <Grid x:Name="RootGrid" Width="30" Height="30">
                                                            <Grid Margin="-3,-5,0,0">
                                                                <TextBlock x:Name="BackgroundGlyph" Text="&#xE0D4;" Foreground="{Binding ElementName=PART_HeaderGrid, Path=Background}"/>
                                                                <TextBlock x:Name="NormalGlyph" Text="{StaticResource SettingsFlyoutBackButtonGlyph}" Foreground="{Binding ElementName=PART_HeaderGrid, Path=Background, Converter={StaticResource ColorContrast}}"/>
                                                                <TextBlock x:Name="ArrowGlyph" Text="&#xE0C4;" Foreground="{Binding ElementName=PART_HeaderGrid, Path=Background}" Opacity="0"/>
                                                            </Grid>
                                                            <Rectangle
                            x:Name="FocusVisualWhite"
                            IsHitTestVisible="False"
                            Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
                            StrokeEndLineCap="Square"
                            StrokeDashArray="1,1"
                            Opacity="0"
                            StrokeDashOffset="1.5"/>
                                                            <Rectangle
                            x:Name="FocusVisualBlack"
                            IsHitTestVisible="False"
                            Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
                            StrokeEndLineCap="Square"
                            StrokeDashArray="1,1"
                            Opacity="0"
                            StrokeDashOffset="0.5"/>

                                                            <VisualStateManager.VisualStateGroups>
                                                                <VisualStateGroup x:Name="CommonStates">
                                                                    <VisualState x:Name="Normal" />
                                                                    <VisualState x:Name="PointerOver">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonPointerOverBackgroundThemeBrush}"/>
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Pressed">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding ElementName=PART_HeaderGrid, Path=Background, Converter={StaticResource ColorContrast}}"/>
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                            <DoubleAnimation
                                            Storyboard.TargetName="ArrowGlyph"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0"/>
                                                                            <DoubleAnimation
                                            Storyboard.TargetName="NormalGlyph"
                                            Storyboard.TargetProperty="Opacity"
                                            To="0"
                                            Duration="0"/>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Disabled">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Visibility">
                                                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                                <VisualStateGroup x:Name="FocusStates">
                                                                    <VisualState x:Name="Focused">
                                                                        <Storyboard>
                                                                            <DoubleAnimation
                                            Storyboard.TargetName="FocusVisualWhite"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0"/>
                                                                            <DoubleAnimation
                                            Storyboard.TargetName="FocusVisualBlack"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0"/>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Unfocused" />
                                                                    <VisualState x:Name="PointerFocused" />
                                                                </VisualStateGroup>
                                                            </VisualStateManager.VisualStateGroups>
                                                        </Grid>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </Grid.Resources>

                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="30" />
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="30"/>
                                    </Grid.ColumnDefinitions>

                                    <Button x:Name="SettingsBackButton" Margin="0,0,0,0" Grid.Column="0" Style="{StaticResource SettingsBackButtonStyle2}" HorizontalAlignment="Left" />

                                    <TextBlock Foreground="{Binding ElementName=PART_HeaderGrid, Path=Background, Converter={StaticResource ColorContrast}}" TextTrimming="WordEllipsis" Margin="10,-2,0,0" Grid.Column="1" FontFamily="Segoe UI" FontWeight="SemiLight" FontSize="24.6667" Text="{TemplateBinding HeaderText}" HorizontalAlignment="Left" />

                                    <Image Source="{TemplateBinding SmallLogoImageSource}" HorizontalAlignment="Right" Grid.Column="2" Margin="0,0,0,0" />

                                </Grid>

                            </Grid>

                            <!-- Settings Panel Content -->
                            <ScrollViewer Background="{TemplateBinding ContentBackgroundBrush}" Foreground="{TemplateBinding ContentForegroundBrush}" Grid.Row="1" VerticalScrollBarVisibility="Auto" ZoomMode="Disabled" x:Name="PART_ContentScrollViewer">
                                <Grid x:Name="SettingsFlyoutContentGrid" Margin="33,22,40,0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                                    <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  />
                                </Grid>
                            </ScrollViewer>

                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:LiveTile">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:LiveTile">
                    <Grid  Background="{TemplateBinding Background}">
                        <Canvas x:Name="Scroller" DataContext="{x:Null}">
                            <StackPanel x:Name="Stack">
                                <StackPanel.RenderTransform>
                                    <TranslateTransform x:Name="Translate" Y="0" />
                                </StackPanel.RenderTransform>
                                <ContentPresenter x:Name="Current"
                                                      DataContext="{x:Null}"
                                                      Content="{Binding}" 
                                                      ContentTemplate="{TemplateBinding ItemTemplate}" />
                                <ContentPresenter  x:Name="Next" 
                                                      DataContext="{x:Null}"
                                                      Content="{Binding}" 
                                                      ContentTemplate="{TemplateBinding ItemTemplate}" />
                            </StackPanel>
                        </Canvas>
                        <Border
                              BorderBrush="{TemplateBinding BorderBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}">
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style TargetType="local:RatingItem">
        <Setter Property="BorderBrush" Value="{StaticResource RatingItemBorderThemeBrush}"/>
        <Setter Property="Background" Value="{StaticResource ApplicationPageBackgroundThemeBrush}" />
        <Setter Property="FontFamily" Value="Segoe UI Symbol" />
        <Setter Property="Margin" Value="6,0,6,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:RatingItem">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PointerOverRatingItem" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PointerPressed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PointerPressedRatingItem" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PointerExited">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PointerPressedRatingItem" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledRatingItem" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledRatingItemBackground" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused" />
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FillStates">
                                <VisualState x:Name="Empty"/>
                                <VisualState x:Name="Partial"/>
                                <VisualState x:Name="Filled"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <TextBlock x:Name="DefaultRatingItem" Text="{TemplateBinding Tag}" Foreground="{StaticResource RatingItemBackgroundThemeBrush}"  FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" />
                        <primitives:LinearClipper RatioVisible="{TemplateBinding DisplayValue}" ExpandDirection="Right">
                            <TextBlock Text="{TemplateBinding Tag}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" />
                        </primitives:LinearClipper>
                        <TextBlock x:Name="PointerOverRatingItem" Opacity="0" Text="{TemplateBinding Tag}" Foreground="{TemplateBinding PointerOverFill}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" />
                        <TextBlock x:Name="PointerPressedRatingItem" Opacity="0" Text="{TemplateBinding Tag}" Foreground="{TemplateBinding PointerPressedFill}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" />
                        <TextBlock x:Name="DisabledRatingItemBackground" Text="{TemplateBinding Tag}" Foreground="{StaticResource RatingItemBackgroundThemeBrush}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" Opacity="0" />
                        <primitives:LinearClipper x:Name="DisabledRatingItem" RatioVisible="{TemplateBinding DisplayValue}" ExpandDirection="Right" Opacity="0">
                            <TextBlock Text="{TemplateBinding Tag}" Foreground="{StaticResource RatingItemDisabledForegroundThemeBrush}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" />
                        </primitives:LinearClipper>
                        <ContentPresenter x:Name="Content" HorizontalAlignment="Left" Margin="{TemplateBinding Padding}" ContentTemplate="{TemplateBinding ContentTemplate}" Grid.RowSpan="2" Grid.Row="1"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:Rating">
        <Setter Property="Background" Value="{StaticResource ApplicationPageBackgroundThemeBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource RatingItemForegroundThemeBrush}" />
        <Setter Property="PointerOverFill" Value="{StaticResource RatingItemPointerOverThemeBrush}" />
        <Setter Property="PointerPressedFill" Value="{StaticResource RatingItemPointerPressedThemeBrush}" />
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="FontSize" Value="28" />
        <Setter Property="Tag" Value="&#xE082;" />
        <Setter Property="Margin" Value="12,0,0,0" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:Rating">
                    <Grid x:Name="Root">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="PointerOver"/>
                                <VisualState x:Name="PointerPressed"/>
                                <VisualState x:Name="PointerExited"/>
                                <VisualState x:Name="Disabled"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused"/>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" Margin="{TemplateBinding Margin}"  BorderThickness="{TemplateBinding BorderThickness}">
                            <ItemsPresenter/>
                        </Border>
                        <Border x:Name="ReadOnlyVisualElement" IsHitTestVisible="False" Opacity="0" Background="#83FFFFFF" BorderBrush="#A5F7F7F7" BorderThickness="{TemplateBinding BorderThickness}"/>
                        <Border x:Name="DisabledVisualElement" IsHitTestVisible="False" Opacity="0" Background="#FF4D4D4D" BorderBrush="#A5F7F7F7" BorderThickness="{TemplateBinding BorderThickness}"/>
                        <Rectangle x:Name="FocusVisualElement" StrokeThickness="1" RadiusX="1" RadiusY="1" IsHitTestVisible="false" Visibility="Collapsed"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ListBoxItem" x:Key="FlipViewIndicatorItem">
        <Setter Property="Padding" Value="0,4,10,4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected"/>
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="PART_FlipViewIndicatorItem">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource FlipViewIndicatorSelectedThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="SelectedUnfocused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="PART_FlipViewIndicatorItem">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource FlipViewIndicatorSelectedThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="SelectedPointerOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Fill" Storyboard.TargetName="PART_FlipViewIndicatorItem">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource FlipViewIndicatorSelectedThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="PART_FlipViewIndicatorItem" 
                                   Width="20" Height="5" Fill="{StaticResource FlipViewIndicatorUnselectedThemeBrush}" 
                                   Margin="0,5,5,0" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:FlipViewIndicator">
        <Setter Property="Margin" Value="3,0,0,0" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource FlipViewIndicatorItem}" />
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" Margin="{TemplateBinding Margin}" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" />
        <Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="True" />
        <Setter Property="ScrollViewer.VerticalScrollMode" Value="Enabled" />
        <Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="True" />
        <Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="TabNavigation" Value="Once" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBox">
                    <Border x:Name="PART_FlipViewIndicatorLayoutRoot" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            Background="{TemplateBinding Background}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="PART_FlipViewIndicatorLayoutRoot">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="PART_FlipViewIndicatorLayoutRoot">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxDisabledForegroundThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="PART_FlipViewIndicatorLayoutRoot">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxFocusBackgroundThemeBrush}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ScrollViewer x:Name="ScrollViewer" 
                                      HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" 
                                      HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" 
                                      IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" 
                                      IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" 
                                      Padding="{TemplateBinding Padding}" TabNavigation="{TemplateBinding TabNavigation}" 
                                      VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" 
                                      VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" 
                                      ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
                            <ItemsPresenter/>
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:WatermarkTextBox">
        <Setter Property="MinWidth" Value="{StaticResource TextControlThemeMinWidth}" />
        <Setter Property="MinHeight" Value="{StaticResource TextControlThemeMinHeight}" />
        <Setter Property="Foreground" Value="{StaticResource TextBoxForegroundThemeBrush}" />
        <Setter Property="Background" Value="{StaticResource TextBoxBackgroundThemeBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource TextBoxBorderThemeBrush}" />
        <Setter Property="BorderThickness" Value="{StaticResource TextControlBorderThemeThickness}" />
        <Setter Property="FontFamily" Value="{StaticResource ContentControlThemeFontFamily}" />
        <Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
        <Setter Property="Padding" Value="{StaticResource TextControlThemePadding}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:WatermarkTextBox">
                    <Grid>
                        <Grid.Resources>
                            <Style x:Name="DeleteButtonStyle" TargetType="Button">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Grid>
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualState x:Name="Normal" />
                                                        <VisualState x:Name="PointerOver">
                                                            <Storyboard>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
                                                                                               Storyboard.TargetProperty="Background">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPointerOverBackgroundThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                                                               Storyboard.TargetProperty="BorderBrush">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPointerOverBorderThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                                                               Storyboard.TargetProperty="Foreground">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPointerOverForegroundThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Pressed">
                                                            <Storyboard>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
                                                                                               Storyboard.TargetProperty="Background">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPressedBackgroundThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                                                               Storyboard.TargetProperty="BorderBrush">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPressedBorderThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                                                               Storyboard.TargetProperty="Foreground">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPressedForegroundThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimation Storyboard.TargetName="BackgroundElement"
                                                                                 Storyboard.TargetProperty="Opacity"
                                                                                 To="0"
                                                                                 Duration="0" />
                                                                <DoubleAnimation Storyboard.TargetName="BorderElement"
                                                                                 Storyboard.TargetProperty="Opacity"
                                                                                 To="0"
                                                                                 Duration="0" />
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>
                                                <Border x:Name="BorderElement"
                                                        BorderBrush="{StaticResource TextBoxButtonBorderThemeBrush}"
                                                        BorderThickness="{TemplateBinding BorderThickness}"/>
                                                <Border x:Name="BackgroundElement"
                                                        Background="{StaticResource TextBoxButtonBackgroundThemeBrush}"
                                                        Margin="{TemplateBinding BorderThickness}">
                                                    <TextBlock x:Name="GlyphElement"
                                                               Foreground="{StaticResource TextBoxButtonForegroundThemeBrush}"
                                                               VerticalAlignment="Center"
                                                               HorizontalAlignment="Center"
                                                               Text="&#xE0A4;"
                                                               FontFamily="{StaticResource SymbolThemeFontFamily}"/>
                                                </Border>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
                                                                       Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledBackgroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledBorderThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackgroundElement"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{StaticResource TextControlBackgroundThemeOpacity}" />
                                        <DoubleAnimation Storyboard.TargetName="BorderElement"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{StaticResource TextControlBorderThemeOpacity}" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackgroundElement"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{StaticResource TextControlPointerOverBackgroundThemeOpacity}" />
                                        <DoubleAnimation Storyboard.TargetName="BorderElement"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{StaticResource TextControlPointerOverBorderThemeOpacity}" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Focused" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="WatermarkStates">
                                <VisualState x:Name="Watermarked">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Watermark" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unwatermarked" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ButtonStates">
                                <VisualState x:Name="ButtonVisible">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DeleteButton"
                                                                       Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="ButtonCollapsed" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Border x:Name="BackgroundElement"
                                Background="{TemplateBinding Background}"
                                Margin="{TemplateBinding BorderThickness}"
                                Grid.ColumnSpan="2"/>
                        <Border x:Name="BorderElement"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Grid.ColumnSpan="2"/>
                        <ScrollViewer x:Name="ContentElement"
                                      HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                                      HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                                      VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                                      VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                                      IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
                                      IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
                                      IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                                      Margin="{TemplateBinding BorderThickness}"
                                      Padding="{TemplateBinding Padding}"
                                      IsTabStop="False"
                                      ZoomMode="Disabled"/>
                        <TextBlock x:Name="PART_Watermark"
                                   Text="{TemplateBinding Watermark}"
                                   Foreground="{StaticResource TextBoxDisabledForegroundThemeBrush}"
                                   FontStyle="Italic"
                                   IsHitTestVisible="False"
                                   Visibility="Collapsed"
                                   Margin="{StaticResource TextControlBorderThemeThickness}"
                                   Padding="{StaticResource TextControlThemePadding}"
                                   FontFamily="{StaticResource ContentControlThemeFontFamily}"
                                   FontSize="{StaticResource ControlContentThemeFontSize}"/>
                        <Button x:Name="DeleteButton"
                                Style="{StaticResource DeleteButtonStyle}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                IsTabStop="False"
                                Grid.Column="1"
                                Visibility="Collapsed"
                                FontSize="{TemplateBinding FontSize}"
                                VerticalAlignment="Stretch"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:NumericUpDown">
        <Setter Property="MinWidth" Value="100" />
        <Setter Property="MinHeight" Value="{StaticResource TextControlThemeMinHeight}" />
        <Setter Property="Foreground" Value="{StaticResource TextBoxForegroundThemeBrush}" />
        <Setter Property="Background" Value="{StaticResource TextBoxBackgroundThemeBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource TextBoxBorderThemeBrush}" />
        <Setter Property="BorderThickness" Value="{StaticResource TextControlBorderThemeThickness}" />
        <Setter Property="FontFamily" Value="{StaticResource ContentControlThemeFontFamily}" />
        <Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
        <Setter Property="Padding" Value="{StaticResource TextControlThemePadding}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:NumericUpDown">
                    <Grid>
                        <Grid.Resources>
                            <Style x:Name="IncrementButtonStyle" TargetType="Button">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Grid>
                                                <VisualStateManager.VisualStateGroups>
                                                    <VisualStateGroup x:Name="CommonStates">
                                                        <VisualState x:Name="Normal" />
                                                        <VisualState x:Name="PointerOver">
                                                            <Storyboard>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
                                                                                               Storyboard.TargetProperty="Background">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPointerOverBackgroundThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                                                               Storyboard.TargetProperty="BorderBrush">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPointerOverBorderThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                                                               Storyboard.TargetProperty="Foreground">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPointerOverForegroundThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Pressed">
                                                            <Storyboard>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
                                                                                               Storyboard.TargetProperty="Background">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPressedBackgroundThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                                                               Storyboard.TargetProperty="BorderBrush">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPressedBorderThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                                                               Storyboard.TargetProperty="Foreground">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxButtonPressedForegroundThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                            </Storyboard>
                                                        </VisualState>
                                                        <VisualState x:Name="Disabled">
                                                            <Storyboard>
                                                                <DoubleAnimation Storyboard.TargetName="BorderElement"
                                                                                 Storyboard.TargetProperty="Opacity"
                                                                                 To="0"
                                                                                 Duration="0" />
                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement" Storyboard.TargetProperty="Foreground">
                                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledForegroundThemeBrush}" />
                                                                </ObjectAnimationUsingKeyFrames>
                                                                <DoubleAnimation Storyboard.TargetName="GlyphElement"
                                                                                 Storyboard.TargetProperty="Opacity"
                                                                                 To=".6"
                                                                                 Duration="0" />
                                                            </Storyboard>
                                                        </VisualState>
                                                    </VisualStateGroup>
                                                </VisualStateManager.VisualStateGroups>
                                                <Border x:Name="BorderElement"
                                                        BorderBrush="{StaticResource TextBoxButtonBorderThemeBrush}"
                                                        BorderThickness="{TemplateBinding BorderThickness}"/>
                                                <Border x:Name="BackgroundElement"
                                                        Background="{StaticResource TextBoxButtonBackgroundThemeBrush}"
                                                        Margin="{TemplateBinding BorderThickness}">
                                                    <TextBlock x:Name="GlyphElement"
                                                               Foreground="{StaticResource TextBoxButtonForegroundThemeBrush}"
                                                               VerticalAlignment="Center"
                                                               HorizontalAlignment="Center"
                                                               Text="{TemplateBinding Content}"
                                                               FontFamily="{StaticResource SymbolThemeFontFamily}"/>
                                                </Border>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
                                                                       Storyboard.TargetProperty="Background">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledBackgroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                                       Storyboard.TargetProperty="BorderBrush">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledBorderThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement"
                                                                       Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource TextBoxDisabledForegroundThemeBrush}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackgroundElement"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{StaticResource TextControlBackgroundThemeOpacity}" />
                                        <DoubleAnimation Storyboard.TargetName="BorderElement"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{StaticResource TextControlBorderThemeOpacity}" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="PointerOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="BackgroundElement"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{StaticResource TextControlPointerOverBackgroundThemeOpacity}" />
                                        <DoubleAnimation Storyboard.TargetName="BorderElement"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{StaticResource TextControlPointerOverBorderThemeOpacity}" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Focused" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="IncrementalButtonStates">
                                <VisualState x:Name="IncrementEnabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_IncrementButton"
                                                                       Storyboard.TargetProperty="IsEnabled">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="True" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="IncrementDisabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_IncrementButton"
                                                                       Storyboard.TargetProperty="IsEnabled">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="False" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="DecrementalButtonStates">
                                <VisualState x:Name="DecrementEnabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_DecrementButton"
                                                                       Storyboard.TargetProperty="IsEnabled">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="True" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="DecrementDisabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_DecrementButton"
                                                                       Storyboard.TargetProperty="IsEnabled">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="False" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Border x:Name="BackgroundElement"
                                Background="{TemplateBinding Background}"
                                Margin="{TemplateBinding BorderThickness}"
                                Grid.ColumnSpan="2"/>
                        <Border x:Name="BorderElement"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Grid.ColumnSpan="2"/>
                        <ScrollViewer x:Name="ContentElement"
                                      HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                                      HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                                      VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                                      VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                                      IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
                                      IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
                                      IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                                      Margin="{TemplateBinding BorderThickness}"
                                      Padding="{TemplateBinding Padding}"
                                      IsTabStop="False"
                                      ZoomMode="Disabled" />
                        <StackPanel Orientation="Horizontal" Grid.Column="1">
                            <Button x:Name="PART_IncrementButton"
                                    Style="{StaticResource IncrementButtonStyle}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    IsTabStop="False" IsEnabled="False"
                                    Content="&#xE109;" FontWeight="Bold"
                                    FontSize="{TemplateBinding FontSize}"
                                    VerticalAlignment="Stretch"/>
                            <Button x:Name="PART_DecrementButton"
                                    Style="{StaticResource IncrementButtonStyle}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    IsTabStop="False" IsEnabled="False"
                                    Content="&#xE108;" FontWeight="Bold"
                                    FontSize="{TemplateBinding FontSize}"
                                    VerticalAlignment="Stretch"/>
                        </StackPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:CustomDialog">
        <Setter Property="IsOpen" Value="False" />
        <Setter Property="BorderThickness" Value="{StaticResource CustomDialogBorderThemeThickness}"/>
        <Setter Property="BorderBrush" Value="{StaticResource CustomDialogBorderThemeBrush}" />
        <Setter Property="BackButtonVisibility" Value="Collapsed" />
        <Setter Property="Background" Value="{StaticResource CustomDialogBackgroundThemeBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CustomDialog">
                    <Popup x:Name="PART_RootPopup" IsLightDismissEnabled="False" IsOpen="{TemplateBinding IsOpen}">
                        <Grid x:Name="PART_RootGrid" Background="#72000000">
                            <Border x:Name="PART_BannerBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" VerticalAlignment="Center">
                                <Grid x:Name="PART_DialogGrid" Background="{TemplateBinding Background}" VerticalAlignment="Center">
                                    <Grid.Resources>
                                        <Style x:Key="DialogBackButtonStyle" TargetType="Button">
                                            <Setter Property="MinWidth" Value="0"/>
                                            <Setter Property="FontFamily" Value="Segoe UI Symbol"/>
                                            <Setter Property="FontWeight" Value="Normal"/>
                                            <Setter Property="FontSize" Value="26.66667"/>
                                            <Setter Property="AutomationProperties.AutomationId" Value="BackButton"/>
                                            <Setter Property="AutomationProperties.Name" Value="Back"/>
                                            <Setter Property="AutomationProperties.ItemType" Value="Navigation Button"/>
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="Button">
                                                        <Grid x:Name="RootGrid" Width="30" Height="30">
                                                            <Grid Margin="-3,-5,0,0">
                                                                <TextBlock x:Name="BackgroundGlyph" Text="&#xE0D4;" Foreground="{Binding ElementName=PART_DialogGrid, Path=Background}"/>
                                                                <TextBlock x:Name="NormalGlyph" Text="{StaticResource SettingsFlyoutBackButtonGlyph}" Foreground="{Binding ElementName=PART_DialogGrid, Path=Background, Converter={StaticResource ColorContrast}}"/>
                                                                <TextBlock x:Name="ArrowGlyph" Text="&#xE0C4;" Foreground="{Binding ElementName=PART_DialogGrid, Path=Background}" Opacity="0"/>
                                                            </Grid>
                                                            <Rectangle
                            x:Name="FocusVisualWhite"
                            IsHitTestVisible="False"
                            Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}"
                            StrokeEndLineCap="Square"
                            StrokeDashArray="1,1"
                            Opacity="0"
                            StrokeDashOffset="1.5"/>
                                                            <Rectangle
                            x:Name="FocusVisualBlack"
                            IsHitTestVisible="False"
                            Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}"
                            StrokeEndLineCap="Square"
                            StrokeDashArray="1,1"
                            Opacity="0"
                            StrokeDashOffset="0.5"/>

                                                            <VisualStateManager.VisualStateGroups>
                                                                <VisualStateGroup x:Name="CommonStates">
                                                                    <VisualState x:Name="Normal" />
                                                                    <VisualState x:Name="PointerOver">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource BackButtonPointerOverBackgroundThemeBrush}"/>
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Pressed">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
                                                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding ElementName=PART_DialogGrid, Path=Background, Converter={StaticResource ColorContrast}}"/>
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                            <DoubleAnimation
                                            Storyboard.TargetName="ArrowGlyph"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0"/>
                                                                            <DoubleAnimation
                                            Storyboard.TargetName="NormalGlyph"
                                            Storyboard.TargetProperty="Opacity"
                                            To="0"
                                            Duration="0"/>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Disabled">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="RootGrid" Storyboard.TargetProperty="Visibility">
                                                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                                <VisualStateGroup x:Name="FocusStates">
                                                                    <VisualState x:Name="Focused">
                                                                        <Storyboard>
                                                                            <DoubleAnimation
                                            Storyboard.TargetName="FocusVisualWhite"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0"/>
                                                                            <DoubleAnimation
                                            Storyboard.TargetName="FocusVisualBlack"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1"
                                            Duration="0"/>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Unfocused" />
                                                                    <VisualState x:Name="PointerFocused" />
                                                                </VisualStateGroup>
                                                            </VisualStateManager.VisualStateGroups>
                                                        </Grid>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </Grid.Resources>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <Border Grid.Column="1" VerticalAlignment="Center">
                                        <StackPanel Margin="13,19,13,25" HorizontalAlignment="Center" Width="{TemplateBinding Width}" MaxWidth="680">
                                            <local:DynamicTextBlock Foreground="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Background, Converter={StaticResource ColorContrast}}" x:Name="PART_Title" Text="{TemplateBinding Title}" FontFamily="Segoe UI" FontSize="26.6667" FontWeight="Light" Margin="0,0,0,8" />
                                            <ContentPresenter Margin="0" x:Name="PART_Content" Foreground="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Background, Converter={StaticResource ColorContrast}}" />
                                        </StackPanel>
                                    </Border>
                                    <Button x:Name="PART_BackButton" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,24,0,0"
                                        Style="{StaticResource DialogBackButtonStyle}" Command="{TemplateBinding BackButtonCommand}" CommandParameter="{TemplateBinding BackButtonCommandParameter}" Visibility="{TemplateBinding BackButtonVisibility}"/>
                                </Grid>
                            </Border>
                        </Grid>
                    </Popup>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

