XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEToolBox

【WPF】XFE工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
<UserControl x:Class="XFEToolBox.WpfCore.Controls.PasswordEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:controls="clr-namespace:XFEToolBox.WpfCore.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800" Name="passwordEditor" MinHeight="34" Focusable="False">
    <!-- UserControl 默认模板会把 Background 画成矩形;这里只承载内容,背景交给下方圆角 Border。 -->
    <UserControl.Template>
        <ControlTemplate TargetType="UserControl">
            <ContentPresenter HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        </ControlTemplate>
    </UserControl.Template>
    <Border x:Name="editorBorder" CornerRadius="{Binding EditorCornerRadius, ElementName=passwordEditor}" Background="{Binding Background, ElementName=passwordEditor}" Padding="{Binding Padding, ElementName=passwordEditor}" SnapsToDevicePixels="True">
        <Border.Style>
            <Style TargetType="Border">
                <Setter Property="BorderBrush" Value="{Binding EditorBorderBrush, ElementName=passwordEditor}"/>
                <Setter Property="BorderThickness" Value="{Binding EditorBorderThickness, ElementName=passwordEditor}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsMouseOver, ElementName=passwordEditor}" Value="True">
                        <Setter Property="BorderBrush" Value="#8080DA"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsKeyboardFocusWithin, ElementName=passwordEditor}" Value="True">
                        <Setter Property="BorderBrush" Value="#7777CF"/>
                        <Setter Property="BorderThickness" Value="1.5"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsEnabled, ElementName=passwordEditor}" Value="False">
                        <Setter Property="Opacity" Value="0.5"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Border.Style>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="25"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <controls:HintTextBox x:Name="hintTextBox" Padding="0" BorderThickness="0" Background="{Binding Background, ElementName=passwordEditor}" Foreground="{Binding Foreground, ElementName=passwordEditor}" FontFamily="{Binding FontFamily, ElementName=passwordEditor}" FontSize="{Binding FontSize, ElementName=passwordEditor}" FontWeight="{Binding FontWeight, ElementName=passwordEditor}" HintBackground="{Binding HintBackground, ElementName=passwordEditor}" Text="{Binding Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ElementName=passwordEditor}" HintForeground="{Binding HintForeground, ElementName=passwordEditor}" HintText="{Binding HintText, ElementName=passwordEditor}" HintFontSize="{Binding HintFontSize, ElementName=passwordEditor}" HintFontFamily="{Binding HintFontFamily, ElementName=passwordEditor}" HintFontWeight="{Binding HintFontWeight, ElementName=passwordEditor}" HintTextHorizontalAlignment="{Binding HintTextHorizontalAlignment, ElementName=passwordEditor}" HintTextVerticalAlignment="{Binding HintTextVerticalAlignment, ElementName=passwordEditor}" HintTextMargin="{Binding HintTextMargin, ElementName=passwordEditor}" HintTextOpacity="{Binding HintTextOpacity, ElementName=passwordEditor}" CaretBrush="{Binding CaretBrush, ElementName=passwordEditor}" SelectionBrush="{Binding SelectionBrush, ElementName=passwordEditor}" SelectionTextBrush="{Binding SelectionTextBrush, ElementName=passwordEditor}" IsReadOnly="{Binding IsReadOnly, ElementName=passwordEditor}" IsReadOnlyCaretVisible="{Binding IsReadOnlyCaretVisible, ElementName=passwordEditor}" HorizontalContentAlignment="{Binding HorizontalContentAlignment, ElementName=passwordEditor}" VerticalContentAlignment="{Binding VerticalContentAlignment, ElementName=passwordEditor}" HorizontalScrollBarVisibility="{Binding HorizontalScrollBarVisibility, ElementName=passwordEditor}" VerticalScrollBarVisibility="{Binding VerticalScrollBarVisibility, ElementName=passwordEditor}" AcceptsReturn="{Binding AcceptsReturn, ElementName=passwordEditor}" AcceptsTab="{Binding AcceptsTab, ElementName=passwordEditor}" IsEnabled="{Binding IsEnabled, ElementName=passwordEditor}" IsInactiveSelectionHighlightEnabled="{Binding IsInactiveSelectionHighlightEnabled, ElementName=passwordEditor}" UndoLimit="{Binding UndoLimit, ElementName=passwordEditor}" IsUndoEnabled="{Binding IsUndoEnabled, ElementName=passwordEditor}" TextWrapping="{Binding TextWrapping, ElementName=passwordEditor}" TextAlignment="{Binding TextAlignment, ElementName=passwordEditor}" TextDecorations="{Binding TextDecorations, ElementName=passwordEditor}" VerticalAlignment="Center"/>
            <Button x:Name="visibleButton" FocusVisualStyle="{x:Null}" Grid.Column="1" Width="23" Height="23" MinWidth="23"
                    Padding="3" BorderThickness="0" controls:ButtonAssist.CornerRadius="8"
                    VerticalAlignment="Center" HorizontalAlignment="Center">
                <Image x:Name="visibilityImage" Source="/XFEToolBox.WpfCore;component/Resources/Image/invisible.png" Margin="3" FocusVisualStyle="{x:Null}"/>
            </Button>
        </Grid>
    </Border>
</UserControl>