TextBoxStyle.xaml 21 KB
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:yomi="clr-namespace:Microsoft.International.Windows.Controls;assembly=YomiganaWPFTextBox">
    <!-- Validate Without RED color -->
    <Style x:Key="DensoTextbox" TargetType="{x:Type TextBox}">
        <Setter Property="Background" Value="White" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="TextWrapping" Value="NoWrap"/>
        <Setter Property="AllowDrop" Value="true" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Height" Value="28"/>
        <Setter Property="Validation.ErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <TextBlock Foreground="Black"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Background" Value="LightGray"/>
                <Setter Property="Opacity" Value="0.5"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ReportMaintenanceTextbox" TargetType="{x:Type TextBox}">
        <Setter Property="Background" Value="White" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="TextWrapping" Value="NoWrap"/>
        <Setter Property="AllowDrop" Value="true" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="HorizontalContentAlignment" Value="Right"/>
        <Setter Property="Height" Value="28"/>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Background" Value="Gray"/>
                <Setter Property="Opacity" Value="0.8"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="DensoTextbox2" TargetType="{x:Type TextBox}">
        <Setter Property="Background" Value="#93b4d4" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Height" Value="26"/>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Background" Value="#0c386f"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <Style x:Key="DensoCommonTextbox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource DensoTextbox}">
        <Setter Property="Margin" Value="5,1"/>
    </Style>

    <Style x:Key="DensoImeTextbox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource DensoTextbox}">
        <Style.Triggers>
            <Trigger Property="IsFocused" Value="True">
                <!--<Setter Property="InputMethod.IsInputMethodEnabled" Value="True"/>-->
                <Setter Property="InputMethod.PreferredImeState" Value="On"/>
                <Setter Property="InputMethod.PreferredImeConversionMode" Value="FullShape,Native"/>
            </Trigger>
            <Trigger Property="IsFocused" Value="False">
                <!--<Setter Property="InputMethod.IsInputMethodEnabled" Value="False"/>-->
                <Setter Property="InputMethod.PreferredImeState" Value="Off"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="DensoCommonImeTextbox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource DensoImeTextbox}">
        <Setter Property="Margin" Value="5,1"/>
        <Setter Property="Height" Value="28"/>
    </Style>

    <Style x:Key="DensoSettingImeTextbox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource DensoImeTextbox}">
        <Setter Property="Margin" Value="5,1"/>
        <Setter Property="Height" Value="25"/>
    </Style>

    <Style x:Key="HomeTextBox" TargetType="{x:Type TextBox}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="White"/>
        <Setter Property="TextWrapping" Value="Wrap"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="Padding" Value="10,30,10,10"/>
    </Style>

    <Style x:Key="RequirementTextBox" TargetType="{x:Type TextBox}" BasedOn="{StaticResource DensoTextbox}">
        <Setter Property="Background" Value="Pink"/>
        <Setter Property="Foreground" Value="#dc2a2a"/>
        <Style.Triggers>
            <!--<EventTrigger RoutedEvent="TextChanged">
                <BeginStoryboard>
                    <Storyboard>
                        -->
            <!--<DoubleAnimation BeginTime="0:0:0"  Duration="0:0:0.300" Storyboard.TargetProperty="FontSize" To="18" />-->
            <!--
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>-->
            <Trigger Property="IsFocused" Value="True">
                <!--<Setter Property="Background" Value="#93b4d4"/>-->
                <!--<Setter Property="Foreground" Value="#dc2a2a"/>-->
            </Trigger>
            <!--<Trigger Property="TextChange." Value="True">
                <Setter Property="Background" Value="#93b4d4"/>
            </Trigger>-->
            <!--<DataTrigger Binding="{Binding ElementName=This, Path=}">
                <Setter Property="Background" Value="Red" />
            </DataTrigger>-->
        </Style.Triggers>
    </Style>
    <Style x:Key="YomiDensoTextbox" TargetType="{x:Type yomi:YomiganaWPFTextBox}">
        <Setter Property="Background" Value="#93b4d4" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Height" Value="26"/>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Background" Value="#0c386f"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--DucTM: begin -->
    <!--NormalTextBoxStyle-->
    <Style x:Key="NormalTextBoxStyle" TargetType="TextBox">
        <Setter Property="TextWrapping" Value="NoWrap"/>
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="Background" Value="#FFFFFFFF" />
        <Setter Property="BorderBrush" Value="#00000000" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="AllowDrop" Value="true" />
        <Setter Property="ToolTipService.ShowDuration" Value="30000"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="MinWidth" Value="0" />
        <Setter Property="MinHeight" Value="0" />
        <Setter Property="Height" Value="30" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                                            <SplineColorKeyFrame KeyTime="0" Value="#FF0091E1" />
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.8" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.2" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="PART_ContentHost" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="DisabledLayer" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="ReadOnly" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusedStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                                            <SplineColorKeyFrame KeyTime="0" Value="#FF0091E1" />
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.8" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <!--<ColorAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Backgroud" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                                            <SplineColorKeyFrame KeyTime="0" Value="#FFE6E6E6" />
                                        </ColorAnimationUsingKeyFrames>-->
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <!--<Border CornerRadius="3" BorderThickness="1" x:Name="Border" Opacity="0.5">-->
                        <Border BorderThickness="1" x:Name="Border" Opacity="0.5">
                            <Border.BorderBrush>
                                <SolidColorBrush Color="#FF005FB4"/>
                            </Border.BorderBrush>
                        </Border>
                        <!--<Border Margin="1" CornerRadius="3" Background="{TemplateBinding Background}" x:Name="Backgroud"/>-->
                        <Border Margin="1" Background="{TemplateBinding Background}" x:Name="Backgroud"/>
                        <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2,2,2,2" />
                        <Border x:Name="DisabledLayer" BorderBrush="{x:Null}" Visibility="Collapsed" Opacity="0.7">
                            <Border.Background>
                                <SolidColorBrush Color="{DynamicResource DisabledColor}"/>
                            </Border.Background>
                        </Border>
                        <Border x:Name="ErrorBorder" BorderThickness="2" Margin="-1" Opacity="0" BorderBrush="Red"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" TargetName="PART_ContentHost" Value="1"/>
                            <Setter Property="Opacity" TargetName="Border" Value="0.2"/>
                        </Trigger>
                        <Trigger Property="Validation.HasError" Value="true">
                            <Setter Property="Foreground" Value="Red"/>
                            <Setter TargetName="ErrorBorder" Property="Opacity" Value="1"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- RequireTextBoxStyle -->
    <Style x:Key="RequireTextBoxStyle" TargetType="TextBox">
        <Setter Property="TextWrapping" Value="NoWrap"/>
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="Background" Value="#FFFFFFFF" />
        <Setter Property="BorderBrush" Value="#00000000" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Padding" Value="1" />
        <Setter Property="AllowDrop" Value="true" />
        <Setter Property="ToolTipService.ShowDuration" Value="30000"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="MinWidth" Value="0" />
        <Setter Property="MinHeight" Value="0" />
        <Setter Property="Height" Value="30" />
        <Setter Property="FontSize" Value="15" />
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                                            <SplineColorKeyFrame KeyTime="0" Value="#FF0091E1" />
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.8" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.2" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="PART_ContentHost" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="DisabledLayer" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="ReadOnly" />
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusedStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
                                            <SplineColorKeyFrame KeyTime="0" Value="#FF0091E1" />
                                        </ColorAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0.8" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <!--<ColorAnimationUsingKeyFrames Duration="00:00:00.001" Storyboard.TargetName="Backgroud" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                                            <SplineColorKeyFrame KeyTime="0" Value="#FFE6E6E6" />
                                        </ColorAnimationUsingKeyFrames>-->
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <!--<Border CornerRadius="3" BorderThickness="1" x:Name="Border" Opacity="0.5">-->
                        <Border BorderThickness="1" x:Name="Border" Opacity="0.5">
                            <Border.BorderBrush>
                                <SolidColorBrush Color="#FF005FB4"/>
                            </Border.BorderBrush>
                        </Border>
                        <!--<Border Margin="1" CornerRadius="3" Background="{TemplateBinding Background}" x:Name="Backgroud"/>-->
                        <Border Margin="1" Background="{TemplateBinding Background}" x:Name="Backgroud"/>
                        <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2,2,2,2" />
                        <Border x:Name="DisabledLayer" BorderBrush="{x:Null}" Visibility="Collapsed" Opacity="0.7">
                            <Border.Background>
                                <SolidColorBrush Color="{DynamicResource DisabledColor}"/>
                            </Border.Background>
                        </Border>
                        <Border x:Name="ErrorBorder" BorderThickness="2" Margin="-1" Opacity="0" BorderBrush="Red"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" TargetName="PART_ContentHost" Value="1"/>
                            <Setter Property="Opacity" TargetName="Border" Value="0.2"/>
                        </Trigger>
                        <Trigger Property="Text" Value="">
                            <Setter Property="Background" Value="#FFFFCCCC" />
                        </Trigger>
                        <Trigger Property="Validation.HasError" Value="true">
                            <Setter Property="Foreground" Value="Red"/>
                            <Setter TargetName="ErrorBorder" Property="Opacity" Value="1"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--DucTM: end -->

    <Style x:Key="DatePickerTextBoxStyle" TargetType="DatePickerTextBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <TextBox x:Name="PART_TextBox" IsReadOnly="True" Style="{DynamicResource DensoTextbox}"
                            Text="{Binding Path= SelectedDate, StringFormat='yyyy/MM/dd',
                            RelativeSource={RelativeSource AncestorType={x:Type DatePicker}},
                            Converter={StaticResource DatePickerCheckEmptyString}}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>