Sunday, May 3, 2015

Custom TextBox and PasswordBox in WPF



 <ControlTemplate x:Key="TextBoxBaseControlTemplate" TargetType="{x:Type TextBoxBase}">
            <Border Background="{TemplateBinding Background}"
                x:Name="Bd" BorderBrush="#FF95C0DB"
                BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="10,10,10,10">
                <ScrollViewer x:Name="PART_ContentHost"/>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                            TargetName="Bd"/>
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                </Trigger>
                <Trigger Property="Width" Value="Auto">
                    <Setter Property="MinWidth" Value="100"/>
                </Trigger>
                <Trigger Property="Height" Value="Auto">
                    <Setter Property="MinHeight" Value="40"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <ControlTemplate x:Key="PasswordBoxControlTemplate" TargetType="{x:Type PasswordBox}">
            <Border Background="{TemplateBinding Background}"
                x:Name="Bd" BorderBrush="#FF95C0DB"
                BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="10,10,10,10">
                <ScrollViewer x:Name="PART_ContentHost"/>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Bd"/>
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                </Trigger>
                <Trigger Property="Width" Value="Auto">
                    <Setter Property="MinWidth" Value="100"/>
                </Trigger>
                <Trigger Property="Height" Value="Auto">
                    <Setter Property="MinHeight" Value="40"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <Style x:Key="{x:Type PasswordBox}"
        TargetType="{x:Type PasswordBox}">
            <Setter Property="local:PasswordBoxMonitor.IsMonitoring"
              Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type PasswordBox}">
                        <Border Name="Bd" BorderBrush="#FF95C0DB"
                BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="10,10,10,10"
                    Background="#FF95C0DB"                  
                    SnapsToDevicePixels="true">
                            <Grid>
                                <ScrollViewer x:Name="PART_ContentHost"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                <TextBlock Text="Password"                         
                           Foreground="White" FontSize="12"
                  FontStyle="Italic" Margin="5,10,0,0"
                  FontFamily="HelveticaNeue-Light,HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica, Arial,Lucida Grande,sans-serif"
                           Visibility="Collapsed"
                           Name="txtPrompt" />
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled"
                                         Value="false">
                                <Setter TargetName="Bd"
                                            Property="Background"
                                            Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                <Setter Property="Foreground"
                                            Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                            <Trigger Property="local:PasswordBoxMonitor.PasswordLength" Value="0">
                                <Setter Property="Visibility" TargetName="txtPrompt" Value="Visible"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

 <TextBox Width="369" Margin="80,0,0,0" Height="32" Grid.Column="0" Grid.Row="3" MaxLength="500"  
                 TabIndex="1" HorizontalAlignment="Center" KeyDown="txtUser_KeyDown_1"
                 Name="txtUser" VerticalAlignment="Top"
                BorderBrush="{x:Null}" Foreground="White" HorizontalContentAlignment="Left"
                 VerticalContentAlignment="Center"
                 FontSize="12" FontStyle="Italic"
                 FontFamily="HelveticaNeue-Light,HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica, Arial,Lucida Grande,sans-serif"
                 Background="Transparent" Text=""
                 Template="{StaticResource TextBoxBaseControlTemplate}">
                </TextBox>
                <PasswordBox Margin="80,0,0,0" Width="369" Height="32" Grid.Column="0" Grid.Row="4" MaxLength="500"  
                 TabIndex="1" HorizontalAlignment="Center" KeyDown="txtPwd_KeyDown_1"
                 Name="txtPassword" VerticalAlignment="Center"
                 BorderBrush="{x:Null}" Foreground="White"
                 HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
                 FontSize="12" FontStyle="Italic"
                 FontFamily="HelveticaNeue-Light,HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica, Arial,Lucida Grande,sans-serif"
                 Background="Transparent" ToolTip="Password">
                </PasswordBox>

Custom ComboBox in WPF




<Style x:Key="Style_1" TargetType="{x:Type ComboBox}">
            <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"></Setter>
            <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
            <Setter Property="BorderBrush" Value="White" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Height" Value="25" />
            <Setter Property="Width" Value="369" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ComboBox}">
                        <Grid>
                            <Border x:Name="ContentPresenterBorder" CornerRadius="10,10,10,10"  BorderThickness="1">
                                <Grid>
                                    <ToggleButton x:Name="DropDownToggle"/>
                                    <ContentPresenter x:Name="ContentPresenter"/>
                                </Grid>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <!--Control colors.-->
        <Color x:Key="WindowColor">#FF95C0DB</Color>
        <Color x:Key="ContentAreaColorLight">#FF95C0DB</Color>
        <Color x:Key="ContentAreaColorDark">#FF95C0DB</Color>

        <Color x:Key="DisabledControlLightColor">#FF95C0DB</Color>
        <Color x:Key="DisabledControlDarkColor">#FF95C0DB</Color>
        <Color x:Key="DisabledForegroundColor">#FF95C0DB</Color>

        <Color x:Key="SelectedBackgroundColor">#FF008EF9</Color>
        <Color x:Key="SelectedUnfocusedColor">#FF95C0DB</Color>

        <Color x:Key="ControlLightColor">#FF95C0DB</Color>
        <Color x:Key="ControlMediumColor">#FF1993BB</Color>
        <Color x:Key="ControlDarkColor">#FF211AA9</Color>

        <Color x:Key="ToggleLightColor">Transparent</Color>
        <Color x:Key="ToggleMediumColor">Transparent</Color>
        <Color x:Key="ToggleDarkColor">Transparent</Color>

        <Color x:Key="ControlMouseOverColor">#FF439DC5</Color>
        <Color x:Key="ControlPressedColor">#FF439DC5</Color>


        <Color x:Key="GlyphColor">Transparent</Color>
        <Color x:Key="GlyphMouseOver">sc#1, 0.004391443, 0.002428215, 0.242281124</Color>

        <!--Border colors-->
        <Color x:Key="BorderLightColor">#FF95C0DB</Color>
        <Color x:Key="BorderMediumColor">#FF95C0DB</Color>
        <Color x:Key="BorderDarkColor">#FF95C0DB</Color>

        <Color x:Key="PressedBorderLightColor">#FF888888</Color>
        <Color x:Key="PressedBorderDarkColor">#FF444444</Color>

        <Color x:Key="DisabledBorderLightColor">#FFAAAAAA</Color>
        <Color x:Key="DisabledBorderDarkColor">#FF888888</Color>

        <Color x:Key="DefaultBorderBrushDarkColor">White</Color>

        <!--Control-specific resources.-->
        <Color x:Key="HeaderTopColor">#FF95C0DB</Color>
        <Color x:Key="DatagridCurrentCellBorderColor">White</Color>
        <Color x:Key="SliderTrackDarkColor">#FF95C0DB</Color>

        <Color x:Key="NavButtonFrameColor">#FF3843C4</Color>

        <LinearGradientBrush x:Key="MenuPopupBrush"
                     EndPoint="0.5,1"
                     StartPoint="0.5,0">
            <GradientStop Color="{DynamicResource ControlLightColor}"
                Offset="0" />
            <GradientStop Color="{DynamicResource ControlMediumColor}"
                Offset="0.5" />
            <GradientStop Color="{DynamicResource ControlLightColor}"
                Offset="1" />
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="ProgressBarIndicatorAnimatedFill"
                     StartPoint="0,0"
                     EndPoint="1,0">
            <LinearGradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#000000FF"
                    Offset="0" />
                    <GradientStop Color="#600000FF"
                    Offset="0.4" />
                    <GradientStop Color="#600000FF"
                    Offset="0.6" />
                    <GradientStop Color="#000000FF"
                    Offset="1" />
                </GradientStopCollection>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
        <ControlTemplate x:Key="ComboBoxToggleButton"
                 TargetType="{x:Type ToggleButton}">
            <Grid >

                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="40" />
                </Grid.ColumnDefinitions>
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal" />
                        <VisualState x:Name="MouseOver">
                            <Storyboard>
                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).
                (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                          Storyboard.TargetName="Border">
                                    <EasingColorKeyFrame KeyTime="0"
                                   Value="{StaticResource ControlMouseOverColor}" />
                                </ColorAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Pressed" />
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).
                (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                          Storyboard.TargetName="Border">
                                    <EasingColorKeyFrame KeyTime="0"
                                   Value="{StaticResource DisabledControlDarkColor}" />
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).
                (SolidColorBrush.Color)"
                                          Storyboard.TargetName="Arrow">
                                    <EasingColorKeyFrame KeyTime="0"
                                   Value="{StaticResource DisabledForegroundColor}" />
                                </ColorAnimationUsingKeyFrames>
                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).
                (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                          Storyboard.TargetName="Border">
                                    <EasingColorKeyFrame KeyTime="0"
                                   Value="{StaticResource DisabledBorderDarkColor}" />
                                </ColorAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="CheckStates">
                        <VisualState x:Name="Checked">
                            <Storyboard>
                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).
                (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                          Storyboard.TargetName="Border">
                                    <EasingColorKeyFrame KeyTime="0"
                                   Value="{StaticResource ControlPressedColor}" />
                                </ColorAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Unchecked" />
                        <VisualState x:Name="Indeterminate" />
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>

                <Border x:Name="Border"
            Grid.ColumnSpan="2" Width="369"
            CornerRadius="10,10,10,10"
            BorderThickness="1">
                    <Border.BorderBrush>
                        <LinearGradientBrush EndPoint="0,1"
                             StartPoint="0,0">
                            <GradientStop Color="{DynamicResource BorderLightColor}"
                        Offset="0" />
                            <GradientStop Color="{DynamicResource BorderDarkColor}"
                        Offset="1" />
                        </LinearGradientBrush>
                    </Border.BorderBrush>
                    <Border.Background>
                        <!--<ImageBrush ImageSource="/POSApplication;component/images/arrow011.png" Stretch="None"/>-->
                        <LinearGradientBrush StartPoint="0,0"
                             EndPoint="0,5">
                            <LinearGradientBrush.GradientStops>
                                <GradientStopCollection>
                                    <GradientStop Color="{DynamicResource ControlLightColor}" />
                                    <GradientStop Color="{DynamicResource ControlMediumColor}" Offset="1.0" />
                                </GradientStopCollection>
                            </LinearGradientBrush.GradientStops>
                        </LinearGradientBrush>
                    </Border.Background>
                </Border>
                <Border Grid.Column="0"
            CornerRadius="10,0,0,10"          
            Margin="1" >
                    <Border.Background>
                        <SolidColorBrush Color="{DynamicResource ControlLightColor}"/>
                    </Border.Background>
                </Border>
                <Image Grid.Column="1" Source="/POSApplication;component/images/arrow01.png"></Image>
            </Grid>
        </ControlTemplate>

        <ControlTemplate x:Key="ComboBoxTextBox"
                 TargetType="{x:Type TextBox}">
            <Border x:Name="PART_ContentHost" Width="369" Focusable="False" CornerRadius="10,0,0,10" BorderThickness="1"
          Background="{TemplateBinding Background}" />
        </ControlTemplate>

        <Style x:Key="{x:Type ComboBox}"
       TargetType="{x:Type ComboBox}">
            <Setter Property="SnapsToDevicePixels"
          Value="true" />
            <Setter Property="HorizontalContentAlignment"
          Value="Left" />
            <Setter Property="VerticalContentAlignment"
          Value="Center" />
            <Setter Property="OverridesDefaultStyle"
          Value="true" />
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
          Value="Auto" />
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
          Value="Auto" />
            <Setter Property="ScrollViewer.CanContentScroll"
          Value="true" />
            <Setter Property="MinWidth"
          Value="120" />
            <Setter Property="MinHeight"
          Value="20" />
            <Setter Property="Width" Value="369"></Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ComboBox}">
                        <Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver" >
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="PART_EditableTextBox"
                                                Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)">
                                                <EasingColorKeyFrame KeyTime="0"
                                         Value="{StaticResource SelectedBackgroundColor}" />
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="PART_EditableTextBox"
                                                Storyboard.TargetProperty="(TextElement.Foreground).
                      (SolidColorBrush.Color)">
                                                <EasingColorKeyFrame KeyTime="0"
                                         Value="{StaticResource DisabledForegroundColor}" />
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="EditStates">
                                    <VisualState x:Name="Editable">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                 Storyboard.TargetName="PART_EditableTextBox">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                            Value="{x:Static Visibility.Visible}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames
                      Storyboard.TargetProperty="(UIElement.Visibility)"
                                                 Storyboard.TargetName="ContentSite">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                            Value="{x:Static Visibility.Hidden}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Uneditable" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ToggleButton x:Name="ToggleButton"
                        Template="{StaticResource ComboBoxToggleButton}"
                        Grid.Column="2"
                        Focusable="false"
                        ClickMode="Press"
                        IsChecked="{Binding IsDropDownOpen, Mode=TwoWay,
              RelativeSource={RelativeSource TemplatedParent}}"/>
                            <ContentPresenter x:Name="ContentSite"
                            IsHitTestVisible="False"
                            Content="{TemplateBinding SelectionBoxItem}"
                            ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                            ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Center"                                            
                            Margin="3,3,23,3">
                            </ContentPresenter>
                            <TextBox x:Name="PART_EditableTextBox"
                   Style="{x:Null}"
                   Template="{StaticResource ComboBoxTextBox}"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Bottom"
                   HorizontalContentAlignment="Left"
                   VerticalContentAlignment="Center"
                                     Width="369"
                   Margin="3,10,23,3"
                   Focusable="True"
                   Background="#FF95C0DB"
                   Visibility="Hidden"
                   IsReadOnly="{TemplateBinding IsReadOnly}" />
                            <Popup x:Name="Popup" Width="369"
                 Placement="Bottom"
                 IsOpen="{TemplateBinding IsDropDownOpen}"
                 AllowsTransparency="True"
                 Focusable="False"
                 PopupAnimation="Slide">
                                <Grid x:Name="DropDown"
                  SnapsToDevicePixels="True"
                  MinWidth="{TemplateBinding ActualWidth}"
                  MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                    <Border x:Name="DropDownBorder"
                                        CornerRadius="10,0,0,10"
                      BorderThickness="1">
                                        <Border.BorderBrush>
                                            <SolidColorBrush Color="{DynamicResource BorderMediumColor}" />
                                        </Border.BorderBrush>
                                        <Border.Background>
                                            <SolidColorBrush Color="{DynamicResource ControlLightColor}" />
                                        </Border.Background>
                                    </Border>
                                    <ScrollViewer Margin="4,6,4,6"
                            SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Hidden">
                                        <StackPanel IsItemsHost="True"
                            KeyboardNavigation.DirectionalNavigation="Contained" />
                                    </ScrollViewer>
                                </Grid>
                            </Popup>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="HasItems"  Value="false">
                                <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95" />
                            </Trigger>
                            <Trigger Property="IsGrouping" Value="true">
                                <Setter Property="ScrollViewer.CanContentScroll" Value="false" />
                            </Trigger>
                            <Trigger SourceName="Popup" Property="AllowsTransparency" Value="true">
                                <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="5,0,0,5" />
                                <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="{x:Type ComboBoxItem}"
       TargetType="{x:Type ComboBoxItem}">          
            <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
            <Setter Property="HorizontalContentAlignment" Value="Left"></Setter>
            <Setter Property="SnapsToDevicePixels" Value="true" />
            <Setter Property="OverridesDefaultStyle" Value="true" />
            <Setter Property="Width" Value="369"></Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                        <Border x:Name="Border" Width="369"
                Padding="2" HorizontalAlignment="Left" VerticalAlignment="Center"                          
                SnapsToDevicePixels="true"
                Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="SelectionStates">
                                    <VisualState x:Name="Unselected" />
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
                                                <EasingColorKeyFrame KeyTime="0"
                                         Value="{StaticResource SelectedBackgroundColor}" />
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                Storyboard.TargetProperty="(Panel.Background).
                    (SolidColorBrush.Color)">
                                                <EasingColorKeyFrame KeyTime="0"
                                         Value="{StaticResource SelectedBackgroundColor}" />
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="SelectedUnfocused">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                Storyboard.TargetProperty="(Panel.Background).
                    (SolidColorBrush.Color)">
                                                <EasingColorKeyFrame KeyTime="0"
                                         Value="{StaticResource SelectedUnfocusedColor}" />
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <ContentPresenter />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsHighlighted" Value="True">
                                <Setter TargetName="Border" Property="Background" Value="#3399FF" />
                                <Setter Property="TextElement.Foreground" Value="White" />
                                <Setter Property="Width" Value="369"></Setter>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False" >
                                <Setter Property="Foreground" Value="#888888" />
                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>



  <ComboBox  Margin="80,0,0,0" Width="369" Height="32" HorizontalAlignment="Center"
                  ItemsSource="{Binding}" Grid.Column="0" Grid.Row="5" 
                  Name="cmbLanguage" VerticalAlignment="Center" KeyDown="cmbLanguage_KeyDown_1"
                  Foreground="White" FontSize="12" VerticalContentAlignment="Center" HorizontalContentAlignment="Left"
                  FontStyle="Italic"
                 FontFamily="HelveticaNeue-Light,HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica, Arial,Lucida Grande,sans-serif"
                  >
                </ComboBox>













Custom MessageBox in WPF



<Window x:Class="POSApplication.CustomMessageBox"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:POSApplication"
    x:Name="_this"
    Height="150"
    Loaded="this_Loaded"
    Style="{DynamicResource MessageBox}"
    Title="MessageBox"
    Width="300"
    WindowStartupLocation="CenterScreen"  >
    <Window.Resources>    

        <Style TargetType="{x:Type Button}">
            <Setter Property="Margin" Value="5,0,0,0" />
            <Setter Property="Width" Value="50" />
        </Style>
    </Window.Resources>
    <DockPanel LastChildFill="True">
        <StackPanel DockPanel.Dock="Top" VerticalAlignment="Top" Margin="0,10,0,0"
                    HorizontalAlignment="Center" Orientation="Horizontal">
            <Grid Height="70">
                <Grid.RowDefinitions>
                    <RowDefinition Height="20"></RowDefinition>
                    <RowDefinition Height="50"></RowDefinition>
                </Grid.RowDefinitions>
                <TextBlock Foreground="#666" Grid.Row="0"
                   Text="{Binding ElementName=_this, Path=Message}"
                   TextWrapping="Wrap" HorizontalAlignment="Center"
                   VerticalAlignment="Top" FontSize="12px"
                   FontFamily="HelveticaNeue-Light,HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica, Arial,Lucida Grande,sans-serif"/>
            <Button x:Name="_ok" Grid.Row="1"
                    Click="ok_Click"
                    Content="_OK" IsDefault="True"
                    Visibility="Collapsed"
                    Background="White" Foreground="#0866c6"
                    BorderBrush="#0866c6" BorderThickness="2"
                    Width="100" Height="32" HorizontalAlignment="Center"
                   VerticalAlignment="Bottom" />
                <Button x:Name="_yes" Grid.Row="1"
                    Click="yes_Click"
                    Content="_Yes"
                     Visibility="Collapsed"
                    Background="White" Foreground="#0866c6"
                    BorderBrush="#0866c6" BorderThickness="1"
                    Width="100" Height="32" HorizontalAlignment="Center"
                   VerticalAlignment="Top" />
                <Button x:Name="_no" Grid.Row="1"
                    Click="no_Click"
                    Content="_No"
                     Visibility="Collapsed"
                    Background="White" Foreground="#0866c6"
                    BorderBrush="#0866c6" BorderThickness="1"
                    Width="100" Height="32" HorizontalAlignment="Center"
                   VerticalAlignment="Top" />
                <Button x:Name="_cancel" Grid.Row="1"
                    Click="cancel_Click"
                    Content="_Cancel" IsCancel="True"
                    Visibility="Collapsed"
                    Background="White" Foreground="#0866c6"
                    BorderBrush="#0866c6" BorderThickness="1"
                    Width="100" Height="32" HorizontalAlignment="Center"
                   VerticalAlignment="Top" />
            </Grid>
        </StackPanel>
       
    </DockPanel>
</Window>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace POSApplication
{
    /// <summary>
    /// Interaction logic for CustomMessageBox.xaml
    /// </summary>
    public partial class CustomMessageBox : Window
    {
        private MessageBoxResult _result = MessageBoxResult.None;
        private Button _close;
        private FrameworkElement _title;

        #region Constructors
        public CustomMessageBox()
        {
            this.InitializeComponent();
        }
        #endregion

        #region Properties
        public string Caption
        {
            get { return this.Title; }
            set { this.Title = value; }
        }

        public MessageBoxResult MessageBoxResult
        {
            get { return this._result; }
            private set
            {
                this._result = value;
                if (MessageBoxResult.Cancel == this._result)
                {
                    this.DialogResult = false;
                }
                else
                {
                    this.DialogResult = true;
                }
            }
        }
        #endregion

        #region Dependency Properties
        public MessageBoxResult DefaultResult
        {
            get { return (MessageBoxResult)GetValue(DefaultResultProperty); }
            set
            {
                SetValue(DefaultResultProperty, value);

                switch (value)
                {
                    case MessageBoxResult.Cancel:
                        this._cancel.IsDefault = true;
                        break;
                    case MessageBoxResult.No:
                        this._no.IsDefault = true;
                        break;
                    case MessageBoxResult.None:
                        break;
                    case MessageBoxResult.OK:
                        this._ok.IsDefault = true;
                        break;
                    case MessageBoxResult.Yes:
                        this._yes.IsDefault = true;
                        break;
                    default:
                        break;
                }
            }
        }

        public static readonly DependencyProperty DefaultResultProperty =
            DependencyProperty.Register("DefaultResult", typeof(MessageBoxResult),
                typeof(CustomMessageBox), new UIPropertyMetadata(MessageBoxResult.None));

        public string Message
        {
            get { return (string)GetValue(MessageProperty); }
            set { SetValue(MessageProperty, value); }
        }

        public static readonly DependencyProperty MessageProperty =
            DependencyProperty.Register("Message", typeof(string),
                typeof(CustomMessageBox), new UIPropertyMetadata(string.Empty));

        public MessageBoxButton MessageBoxButton
        {
            get { return (MessageBoxButton)GetValue(MessageBoxButtonProperty); }
            set
            {
                SetValue(MessageBoxButtonProperty, value);

                switch (value)
                {
                    case MessageBoxButton.OK:
                        this._ok.Visibility = Visibility.Visible;
                        break;
                    case MessageBoxButton.OKCancel:
                        this._ok.Visibility = Visibility.Visible;
                        this._cancel.Visibility = Visibility.Visible;
                        break;
                    case MessageBoxButton.YesNo:
                        this._yes.Visibility = Visibility.Visible;
                        this._no.Visibility = Visibility.Visible;
                        break;
                    case MessageBoxButton.YesNoCancel:
                        this._yes.Visibility = Visibility.Visible;
                        this._no.Visibility = Visibility.Visible;
                        this._cancel.Visibility = Visibility.Visible;
                        break;
                    default:
                        break;
                }
            }
        }

        public static readonly DependencyProperty MessageBoxButtonProperty =
            DependencyProperty.Register("MessageBoxButton", typeof(MessageBoxButton),
                typeof(CustomMessageBox), new UIPropertyMetadata(MessageBoxButton.OK));

        public MessageBoxImage MessageBoxImage
        {
            get { return (MessageBoxImage)GetValue(MessageBoxImageProperty); }
            set { SetValue(MessageBoxImageProperty, value); }
        }

        public static readonly DependencyProperty MessageBoxImageProperty =
            DependencyProperty.Register("MessageBoxImage", typeof(MessageBoxImage),
                typeof(CustomMessageBox), new UIPropertyMetadata(MessageBoxImage.None));
        #endregion

        #region Static Methods
        public static MessageBoxResult Show(string messageBoxText)
        {
            return Show(null, messageBoxText, string.Empty,
                MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.None);
        }

        public static MessageBoxResult Show(string messageBoxText, string caption)
        {
            return Show(null, messageBoxText, caption, MessageBoxButton.OK,
                MessageBoxImage.None, MessageBoxResult.None);
        }

        public static MessageBoxResult Show(Window owner, string messageBoxText)
        {
            return Show(owner, messageBoxText, string.Empty, MessageBoxButton.OK,
                MessageBoxImage.None, MessageBoxResult.None);
        }

        public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
        {
            return Show(null, messageBoxText, caption, button, MessageBoxImage.None,
                MessageBoxResult.None);
        }

        public static MessageBoxResult Show(Window owner, string messageBoxText, string caption)
        {
            return Show(owner, messageBoxText, caption, MessageBoxButton.OK,
                MessageBoxImage.None, MessageBoxResult.None);
        }

        public static MessageBoxResult Show(string messageBoxText, string caption,
            MessageBoxButton button, MessageBoxImage icon)
        {
            return Show(null, messageBoxText, caption, button, icon,
                MessageBoxResult.None);
        }

        public static MessageBoxResult Show(Window owner, string messageBoxText, string caption,
            MessageBoxButton button)
        {
            return Show(owner, messageBoxText, caption, button,
                MessageBoxImage.None, MessageBoxResult.None);
        }

        public static MessageBoxResult Show(string messageBoxText, string caption,
            MessageBoxButton button, MessageBoxImage image, MessageBoxResult defaultResult)
        {
            return Show(null, messageBoxText, caption, button, image, defaultResult);
        }

        public static MessageBoxResult Show(Window owner, string messageBoxText, string caption,
            MessageBoxButton button, MessageBoxImage icon)
        {
            return Show(owner, messageBoxText, caption, button, icon, MessageBoxResult.None);
        }

        public static MessageBoxResult Show(Window owner, string messageBoxText,
            string caption, MessageBoxButton button, MessageBoxImage icon,
            MessageBoxResult defaultResult)
        {
            CustomMessageBox messageBox = new CustomMessageBox();
            messageBox.Caption = caption;
            messageBox.DefaultResult = defaultResult;
            messageBox.Owner = owner;
            messageBox.Message = messageBoxText;
            messageBox.MessageBoxButton = button;
            messageBox.MessageBoxImage = icon;
            if (false == messageBox.ShowDialog())
            {
                return MessageBoxResult.Cancel;
            }

            return messageBox.MessageBoxResult;
        }
        #endregion

        #region Event Handlers
        private void cancel_Click(object sender, RoutedEventArgs e)
        {
            this.MessageBoxResult = MessageBoxResult.Cancel;
        }

        private void no_Click(object sender, RoutedEventArgs e)
        {
            this.MessageBoxResult = MessageBoxResult.No;
        }

        private void ok_Click(object sender, RoutedEventArgs e)
        {
            this.MessageBoxResult = MessageBoxResult.OK;
        }

        private void this_Loaded(object sender, RoutedEventArgs e)
        {
            this._close = (Button)this.Template.FindName("PART_Close", this);
            if (null != this._close)
            {
                if (false == this._cancel.IsVisible)
                {
                    this._close.IsCancel = false;
                }
            }

            this._title = (FrameworkElement)this.Template.FindName("PART_Title", this);
            if (null != this._title)
            {
                this._title.MouseLeftButtonDown += new MouseButtonEventHandler(title_MouseLeftButtonDown);
            }
        }

        private void title_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            DragMove();
        }

        private void yes_Click(object sender, RoutedEventArgs e)
        {
            this.MessageBoxResult = MessageBoxResult.Yes;
        }
        #endregion
    }
}















Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...