<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls"
                    xmlns:Converters="clr-namespace:MahApps.Metro.Converters">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Shared.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

    <!--  TextBox Style  -->
    <Style x:Key="MetroTextBox" TargetType="{x:Type TextBox}">
        <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CaretBrush" Value="{DynamicResource BlackBrush}" />
        <Setter Property="ContextMenu" Value="{DynamicResource TextBoxMetroContextMenu}" />
        <Setter Property="Controls:ControlsHelper.FocusBorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
        <Setter Property="Controls:ControlsHelper.MouseOverBorderBrush" Value="{DynamicResource TextBoxMouseOverBorderBrush}" />
        <Setter Property="Controls:TextBoxHelper.ButtonFontSize" Value="{DynamicResource ClearTextButtonFontSize}" />
        <Setter Property="Controls:TextBoxHelper.ButtonWidth" Value="22" />
        <Setter Property="Controls:TextBoxHelper.IsMonitoring" Value="True" />
        <Setter Property="Controls:TextBoxHelper.IsSpellCheckContextMenuEnabled" Value="{Binding RelativeSource={RelativeSource Self}, Path=(SpellCheck.IsEnabled)}" />
        <Setter Property="Controls:TextBoxHelper.WatermarkWrapping" Value="{Binding RelativeSource={RelativeSource Self}, Path=TextWrapping, Mode=OneWay}" />
        <Setter Property="FontFamily" Value="{DynamicResource ContentFontFamily}" />
        <Setter Property="FontSize" Value="{DynamicResource ContentFontSize}" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="MinHeight" Value="26" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="SelectionBrush" Value="{DynamicResource HighlightBrush}" />
        <!--  change SnapsToDevicePixels to True to view a better border and validation error  -->
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="enterGotFocus">
                            <DoubleAnimation Storyboard.TargetName="PART_Message"
                                             Storyboard.TargetProperty="Opacity"
                                             To=".2"
                                             Duration="0:0:0.2" />
                        </Storyboard>
                        <Storyboard x:Key="exitGotFocus">
                            <DoubleAnimation Storyboard.TargetName="PART_Message"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0:0:0.2" />
                        </Storyboard>

                        <Storyboard x:Key="enterHasText">
                            <DoubleAnimation Storyboard.TargetName="PART_Message"
                                             Storyboard.TargetProperty="Opacity"
                                             From=".2"
                                             To="0"
                                             Duration="0:0:0.2" />
                        </Storyboard>
                        <Storyboard x:Key="exitHasText">
                            <DoubleAnimation Storyboard.TargetName="PART_Message"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0:0:0.2" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <AdornerDecorator x:Name="PART_WaitingForDataEffectAdornerDecorator" Visibility="Collapsed">
                            <Border x:Name="PART_WaitingForDataEffectGrid"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="Transparent"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Effect="{DynamicResource WaitingForDataEffect}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </AdornerDecorator>
                        <Border x:Name="Base"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Grid x:Name="PART_InnerGrid" Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="TextColumn" Width="*" />
                                <ColumnDefinition x:Name="ButtonColumn" Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition x:Name="ButtonRow" Height="*" />
                            </Grid.RowDefinitions>

                            <ScrollViewer x:Name="PART_ContentHost"
                                          Grid.Row="1"
                                          Grid.Column="0"
                                          Margin="2"
                                          VerticalAlignment="Stretch"
                                          Background="{x:Null}"
                                          BorderThickness="0"
                                          IsTabStop="False" />
                            <TextBlock x:Name="PART_Message"
                                       Grid.Row="1"
                                       Grid.Column="0"
                                       Margin="6 2 6 2"
                                       Padding="{TemplateBinding Padding}"
                                       HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                       Foreground="{TemplateBinding Foreground}"
                                       Style="{DynamicResource MahApps.Metro.Styles.MetroWatermarkTextBlock}"
                                       Text="{TemplateBinding Controls:TextBoxHelper.Watermark}"
                                       TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
                                       TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}"
                                       TextWrapping="{TemplateBinding Controls:TextBoxHelper.WatermarkWrapping}"
                                       Visibility="Collapsed" />
                            <ContentControl x:Name="PART_FloatingMessageContainer"
                                            Grid.Row="0"
                                            Grid.Column="0"
                                            Style="{DynamicResource FloatingMessageContainerStyle}">
                                <ContentControl.Height>
                                    <MultiBinding Converter="{Converters:MathMultiplyConverter}">
                                        <Binding ElementName="PART_FloatingMessage"
                                                 Mode="OneWay"
                                                 Path="ActualHeight" />
                                        <Binding ElementName="PART_FloatingMessageContainer"
                                                 Mode="OneWay"
                                                 Path="Opacity" />
                                    </MultiBinding>
                                </ContentControl.Height>
                                <TextBlock x:Name="PART_FloatingMessage"
                                           HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                           VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                           Foreground="{TemplateBinding Foreground}"
                                           Style="{DynamicResource MetroAutoCollapsingTextBlock}"
                                           Text="{TemplateBinding Controls:TextBoxHelper.Watermark}"
                                           TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
                                           TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}">
                                    <TextBlock.RenderTransform>
                                        <TranslateTransform x:Name="FloatingMessageTransform">
                                            <TranslateTransform.Y>
                                                <MultiBinding Converter="{Converters:MathSubtractConverter}">
                                                    <Binding ElementName="PART_FloatingMessage"
                                                             Mode="OneWay"
                                                             Path="ActualHeight" />
                                                    <Binding ElementName="PART_FloatingMessageContainer"
                                                             Mode="OneWay"
                                                             Path="ActualHeight" />
                                                </MultiBinding>
                                            </TranslateTransform.Y>
                                        </TranslateTransform>
                                    </TextBlock.RenderTransform>
                                </TextBlock>
                            </ContentControl>
                            <Button x:Name="PART_ClearText"
                                    Grid.Row="0"
                                    Grid.RowSpan="2"
                                    Grid.Column="1"
                                    Width="{TemplateBinding Controls:TextBoxHelper.ButtonWidth}"
                                    Controls:TextBoxHelper.IsClearTextButtonBehaviorEnabled="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextBoxHelper.ClearTextButton), Mode=OneWay}"
                                    Content="{TemplateBinding Controls:TextBoxHelper.ButtonContent}"
                                    ContentTemplate="{TemplateBinding Controls:TextBoxHelper.ButtonContentTemplate}"
                                    Focusable="False"
                                    FontFamily="{TemplateBinding Controls:TextBoxHelper.ButtonFontFamily}"
                                    FontSize="{TemplateBinding Controls:TextBoxHelper.ButtonFontSize}"
                                    Foreground="{TemplateBinding Foreground}"
                                    IsTabStop="False"
                                    Style="{DynamicResource ChromelessButtonStyle}"
                                    Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextBoxHelper.ClearTextButton), Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}" />
                        </Grid>
                        <Border x:Name="DisabledVisualElement"
                                Background="{DynamicResource ControlsDisabledBrush}"
                                BorderBrush="{DynamicResource ControlsDisabledBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                IsHitTestVisible="False"
                                Opacity="0"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.DisabledVisualElementVisibility), Mode=OneWay}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.ButtonsAlignment)}" Value="Left">
                            <Setter TargetName="ButtonColumn" Property="Width" Value="*" />
                            <Setter TargetName="PART_ClearText" Property="Grid.Column" Value="0" />
                            <Setter TargetName="PART_ContentHost" Property="Grid.Column" Value="1" />
                            <Setter TargetName="PART_Message" Property="Grid.Column" Value="1" />
                            <Setter TargetName="TextColumn" Property="Width" Value="Auto" />
                        </DataTrigger>

                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
                            <Setter TargetName="PART_Message" Property="Visibility" Value="Visible" />
                        </DataTrigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding Path=IsVisible, RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding Path=(Controls:TextBoxHelper.UseFloatingWatermark), RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding Path=(Controls:TextBoxHelper.HasText), RelativeSource={RelativeSource Self}}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <MultiDataTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource ShowFloatingMessageStoryboard}" />
                            </MultiDataTrigger.EnterActions>
                            <MultiDataTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HideFloatingMessageStoryboard}" />
                            </MultiDataTrigger.ExitActions>
                        </MultiDataTrigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.ButtonsAlignment)}" Value="Right" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.ClearTextButton)}" Value="False" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="PART_ContentHost" Property="Grid.ColumnSpan" Value="2" />
                            <Setter TargetName="PART_Message" Property="Grid.ColumnSpan" Value="2" />
                        </MultiDataTrigger>

                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Base" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.MouseOverBorderBrush)}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="DisabledVisualElement" Property="Opacity" Value="0.6" />
                        </Trigger>
                        <Trigger Property="IsReadOnly" Value="True">
                            <Setter TargetName="PART_ClearText" Property="IsEnabled" Value="False" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="Base" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.FocusBorderBrush)}" />
                            <Setter TargetName="PART_FloatingMessage" Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
                            <Setter TargetName="PART_FloatingMessage" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger SourceName="PART_ClearText" Property="IsMouseOver" Value="True">
                            <Setter TargetName="PART_ClearText" Property="Background" Value="{DynamicResource GrayBrush8}" />
                            <Setter TargetName="PART_ClearText" Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
                        </Trigger>
                        <Trigger SourceName="PART_ClearText" Property="IsPressed" Value="True">
                            <Setter TargetName="PART_ClearText" Property="Background" Value="{DynamicResource BlackBrush}" />
                            <Setter TargetName="PART_ClearText" Property="Foreground" Value="{DynamicResource WhiteBrush}" />
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Controls:TextBoxHelper.HasText" Value="False" />
                                <Condition Property="IsFocused" Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource enterGotFocus}" />
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource exitGotFocus}" />
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>

                        <Trigger Property="Controls:TextBoxHelper.HasText" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource enterHasText}" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource exitHasText}" />
                            </Trigger.ExitActions>
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsVisible" Value="True" />
                                <Condition Property="Controls:TextBoxHelper.IsWaitingForData" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_WaitingForDataEffectAdornerDecorator" Property="Visibility" Value="Visible" />
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource WaitingForDataStoryboard}" />
                            </MultiTrigger.EnterActions>
                        </MultiTrigger>
                        <Trigger Property="Controls:TextBoxHelper.IsWaitingForData" Value="False">
                            <Setter TargetName="PART_WaitingForDataEffectAdornerDecorator" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Validation.ErrorTemplate" Value="{DynamicResource ValidationErrorTemplate}" />
    </Style>

    <Style x:Key="MetroButtonTextBox"
           BasedOn="{StaticResource MetroTextBox}"
           TargetType="{x:Type TextBox}">
        <Setter Property="Controls:TextBoxHelper.ButtonTemplate" Value="{DynamicResource ChromelessButtonTemplate}" />
        <Setter Property="Controls:TextBoxHelper.TextButton" Value="True" />
        <!--  change SnapsToDevicePixels to True to view a better border and validation error  -->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="enterGotFocus">
                            <DoubleAnimation Storyboard.TargetName="PART_Message"
                                             Storyboard.TargetProperty="Opacity"
                                             To=".2"
                                             Duration="0:0:0.2" />
                        </Storyboard>
                        <Storyboard x:Key="exitGotFocus">
                            <DoubleAnimation Storyboard.TargetName="PART_Message"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0:0:0.2" />
                        </Storyboard>

                        <Storyboard x:Key="enterHasText">
                            <DoubleAnimation Storyboard.TargetName="PART_Message"
                                             Storyboard.TargetProperty="Opacity"
                                             From=".2"
                                             To="0"
                                             Duration="0:0:0.2" />
                        </Storyboard>
                        <Storyboard x:Key="exitHasText">
                            <DoubleAnimation Storyboard.TargetName="PART_Message"
                                             Storyboard.TargetProperty="Opacity"
                                             Duration="0:0:0.2" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <AdornerDecorator x:Name="PART_WaitingForDataEffectAdornerDecorator" Visibility="Collapsed">
                            <Border x:Name="PART_WaitingForDataEffectGrid"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="Transparent"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Effect="{DynamicResource WaitingForDataEffect}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </AdornerDecorator>
                        <Border x:Name="Base"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Grid x:Name="PART_InnerGrid" Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="TextColumn" Width="*" />
                                <ColumnDefinition x:Name="ButtonColumn" Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition x:Name="ButtonRow" Height="*" />
                            </Grid.RowDefinitions>

                            <ScrollViewer x:Name="PART_ContentHost"
                                          Grid.Row="1"
                                          Grid.Column="0"
                                          Margin="2"
                                          VerticalAlignment="Stretch"
                                          Background="{x:Null}"
                                          BorderThickness="0"
                                          IsTabStop="False" />
                            <TextBlock x:Name="PART_Message"
                                       Grid.Row="1"
                                       Grid.Column="0"
                                       Margin="6 2 6 2"
                                       Padding="{TemplateBinding Padding}"
                                       HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                       Foreground="{TemplateBinding Foreground}"
                                       Style="{DynamicResource MahApps.Metro.Styles.MetroWatermarkTextBlock}"
                                       Text="{TemplateBinding Controls:TextBoxHelper.Watermark}"
                                       TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
                                       TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}"
                                       TextWrapping="{TemplateBinding Controls:TextBoxHelper.WatermarkWrapping}"
                                       Visibility="Collapsed" />
                            <ContentControl x:Name="PART_FloatingMessageContainer"
                                            Grid.Row="0"
                                            Grid.Column="0"
                                            Style="{DynamicResource FloatingMessageContainerStyle}">
                                <ContentControl.Height>
                                    <MultiBinding Converter="{Converters:MathMultiplyConverter}">
                                        <Binding ElementName="PART_FloatingMessage"
                                                 Mode="OneWay"
                                                 Path="ActualHeight" />
                                        <Binding ElementName="PART_FloatingMessageContainer"
                                                 Mode="OneWay"
                                                 Path="Opacity" />
                                    </MultiBinding>
                                </ContentControl.Height>
                                <TextBlock x:Name="PART_FloatingMessage"
                                           HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                           VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                           Foreground="{TemplateBinding Foreground}"
                                           Style="{DynamicResource MetroAutoCollapsingTextBlock}"
                                           Text="{TemplateBinding Controls:TextBoxHelper.Watermark}"
                                           TextAlignment="{TemplateBinding Controls:TextBoxHelper.WatermarkAlignment}"
                                           TextTrimming="{TemplateBinding Controls:TextBoxHelper.WatermarkTrimming}">
                                    <TextBlock.RenderTransform>
                                        <TranslateTransform x:Name="FloatingMessageTransform">
                                            <TranslateTransform.Y>
                                                <MultiBinding Converter="{Converters:MathSubtractConverter}">
                                                    <Binding ElementName="PART_FloatingMessage"
                                                             Mode="OneWay"
                                                             Path="ActualHeight" />
                                                    <Binding ElementName="PART_FloatingMessageContainer"
                                                             Mode="OneWay"
                                                             Path="ActualHeight" />
                                                </MultiBinding>
                                            </TranslateTransform.Y>
                                        </TranslateTransform>
                                    </TextBlock.RenderTransform>
                                </TextBlock>
                            </ContentControl>
                            <Button x:Name="PART_ClearText"
                                    Grid.Row="0"
                                    Grid.RowSpan="2"
                                    Grid.Column="1"
                                    Width="{TemplateBinding Controls:TextBoxHelper.ButtonWidth}"
                                    Controls:TextBoxHelper.IsClearTextButtonBehaviorEnabled="True"
                                    Content="{TemplateBinding Controls:TextBoxHelper.ButtonContent}"
                                    ContentTemplate="{TemplateBinding Controls:TextBoxHelper.ButtonContentTemplate}"
                                    Focusable="False"
                                    FontFamily="{TemplateBinding Controls:TextBoxHelper.ButtonFontFamily}"
                                    FontSize="{TemplateBinding Controls:TextBoxHelper.ButtonFontSize}"
                                    Foreground="{TemplateBinding Foreground}"
                                    IsTabStop="False"
                                    Style="{DynamicResource ChromelessButtonStyle}"
                                    Template="{TemplateBinding Controls:TextBoxHelper.ButtonTemplate}"
                                    Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextBoxHelper.TextButton), Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}" />
                        </Grid>
                        <Border x:Name="DisabledVisualElement"
                                Background="{DynamicResource ControlsDisabledBrush}"
                                BorderBrush="{DynamicResource ControlsDisabledBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                IsHitTestVisible="False"
                                Opacity="0"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.DisabledVisualElementVisibility), Mode=OneWay}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.ButtonsAlignment)}" Value="Left">
                            <Setter TargetName="ButtonColumn" Property="Width" Value="*" />
                            <Setter TargetName="PART_ClearText" Property="Grid.Column" Value="0" />
                            <Setter TargetName="PART_ContentHost" Property="Grid.Column" Value="1" />
                            <Setter TargetName="PART_Message" Property="Grid.Column" Value="1" />
                            <Setter TargetName="TextColumn" Property="Width" Value="Auto" />
                        </DataTrigger>

                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
                            <Setter TargetName="PART_Message" Property="Visibility" Value="Visible" />
                        </DataTrigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding Path=IsVisible, RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding Path=(Controls:TextBoxHelper.UseFloatingWatermark), RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding Path=(Controls:TextBoxHelper.HasText), RelativeSource={RelativeSource Self}}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <MultiDataTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource ShowFloatingMessageStoryboard}" />
                            </MultiDataTrigger.EnterActions>
                            <MultiDataTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HideFloatingMessageStoryboard}" />
                            </MultiDataTrigger.ExitActions>
                        </MultiDataTrigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.ButtonsAlignment)}" Value="Right" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextBoxHelper.TextButton)}" Value="False" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="PART_ContentHost" Property="Grid.ColumnSpan" Value="2" />
                            <Setter TargetName="PART_Message" Property="Grid.ColumnSpan" Value="2" />
                        </MultiDataTrigger>

                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Base" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.MouseOverBorderBrush)}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="DisabledVisualElement" Property="Opacity" Value="0.6" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsReadOnly" Value="True" />
                                <Condition Property="Controls:TextBoxHelper.ButtonCommand" Value="{x:Null}" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_ClearText" Property="IsEnabled" Value="False" />
                        </MultiTrigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="Base" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.FocusBorderBrush)}" />
                            <Setter TargetName="PART_FloatingMessage" Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
                            <Setter TargetName="PART_FloatingMessage" Property="Opacity" Value="1" />
                        </Trigger>
                        <Trigger SourceName="PART_ClearText" Property="IsMouseOver" Value="True">
                            <Setter TargetName="PART_ClearText" Property="Background" Value="{DynamicResource GrayBrush8}" />
                            <Setter TargetName="PART_ClearText" Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
                        </Trigger>
                        <Trigger SourceName="PART_ClearText" Property="IsPressed" Value="True">
                            <Setter TargetName="PART_ClearText" Property="Background" Value="{DynamicResource BlackBrush}" />
                            <Setter TargetName="PART_ClearText" Property="Foreground" Value="{DynamicResource WhiteBrush}" />
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsVisible" Value="True" />
                                <Condition Property="Controls:TextBoxHelper.IsWaitingForData" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_WaitingForDataEffectAdornerDecorator" Property="Visibility" Value="Visible" />
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource WaitingForDataStoryboard}" />
                            </MultiTrigger.EnterActions>
                        </MultiTrigger>
                        <Trigger Property="Controls:TextBoxHelper.IsWaitingForData" Value="False">
                            <Setter TargetName="PART_WaitingForDataEffectAdornerDecorator" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  obsolete  -->
    <Style x:Key="ButtonCommandMetroTextBox"
           BasedOn="{StaticResource MetroButtonTextBox}"
           TargetType="{x:Type TextBox}" />

    <Style x:Key="SearchMetroTextBox"
           BasedOn="{StaticResource MetroButtonTextBox}"
           TargetType="{x:Type TextBox}">
        <Setter Property="Controls:TextBoxHelper.ButtonContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <!--  Modern - Magnify  -->
                    <ContentControl x:Name="PART_PackIcon"
                                    Width="{Binding RelativeSource={RelativeSource AncestorType=TextBox}, Path=(Controls:TextBoxHelper.ButtonWidth), Mode=OneWay}"
                                    Height="{Binding RelativeSource={RelativeSource AncestorType=TextBox}, Path=(Controls:TextBoxHelper.ButtonWidth), Mode=OneWay}"
                                    Padding="3"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    Content="M42.5,22A12.5,12.5 0 0,1 55,34.5A12.5,12.5 0 0,1 42.5,47C40.14,47 37.92,46.34 36,45.24L26.97,54.27C25.8,55.44 23.9,55.44 22.73,54.27C21.56,53.1 21.56,51.2 22.73,50.03L31.8,40.96C30.66,39.08 30,36.86 30,34.5A12.5,12.5 0 0,1 42.5,22M42.5,26A8.5,8.5 0 0,0 34,34.5A8.5,8.5 0 0,0 42.5,43A8.5,8.5 0 0,0 51,34.5A8.5,8.5 0 0,0 42.5,26Z"
                                    Style="{DynamicResource PathIconContentControlStyle}" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MetroRichTextBox" TargetType="{x:Type RichTextBox}">
        <Style.Resources>
            <Style BasedOn="{StaticResource {x:Type Hyperlink}}" TargetType="{x:Type Hyperlink}">
                <Setter Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
                <Setter Property="TextDecorations" Value="Underline" />
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Foreground" Value="{DynamicResource HighlightBrush}" />
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="False">
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="True">
                        <Setter Property="Cursor" Value="Hand" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Style.Resources>
        <Setter Property="AllowDrop" Value="True" />
        <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource TextBoxBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CaretBrush" Value="{DynamicResource BlackBrush}" />
        <Setter Property="ContextMenu" Value="{DynamicResource TextBoxMetroContextMenu}" />
        <Setter Property="Controls:ControlsHelper.FocusBorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
        <Setter Property="Controls:ControlsHelper.MouseOverBorderBrush" Value="{DynamicResource TextBoxMouseOverBorderBrush}" />
        <Setter Property="Controls:TextBoxHelper.IsSpellCheckContextMenuEnabled" Value="{Binding RelativeSource={RelativeSource Self}, Path=(SpellCheck.IsEnabled)}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="FontFamily" Value="{DynamicResource ContentFontFamily}" />
        <Setter Property="FontSize" Value="{DynamicResource ContentFontSize}" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="MinHeight" Value="26" />
        <Setter Property="MinWidth" Value="10" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
        <Setter Property="SelectionBrush" Value="{DynamicResource HighlightBrush}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBoxBase}">
                    <Grid>
                        <Border x:Name="Bd"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                        <Border x:Name="DisabledVisualElement"
                                Background="{DynamicResource ControlsDisabledBrush}"
                                BorderBrush="{DynamicResource ControlsDisabledBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                IsHitTestVisible="False"
                                Opacity="0"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.DisabledVisualElementVisibility), Mode=OneWay}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.MouseOverBorderBrush)}" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter TargetName="Bd" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.FocusBorderBrush)}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="DisabledVisualElement" Property="Opacity" Value="0.6" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>



