(精华)2020年01月24日 WPF课程管理系统项目实战(登陆界面-界面布局)

一.登录界面布局

<Window x:Class="Zhaoxi.CourseManagement.View.LoginView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Zhaoxi.CourseManagement.View"
        xmlns:common="clr-namespace:Zhaoxi.CourseManagement.Common"
        mc:Ignorable="d" Name="window"
        Title="系统登录" Height="600" Width="360"
        FontFamily="Microsoft YaHei" FontWeight="ExtraLight"
        ResizeMode="NoResize" WindowStartupLocation="CenterScreen" 
        WindowStyle="None" AllowsTransparency="True" Background="{x:Null}">
    <Window.Resources>
        <ResourceDictionary Source="../Assets/Styles/DefaultStyle.xaml">
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary>
                    <ControlTemplate TargetType="Button" x:Key="LoginButtonTemplate">
                        <Border Background="#007DFA" CornerRadius="5">
                            <Grid>
                                <Border CornerRadius="4" Background="#22FFFFFF" Name="back" Visibility="Hidden"/>
                                <ContentControl Content="{TemplateBinding Content}"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center"
                                Foreground="{TemplateBinding Foreground}"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Visibility" Value="Visible" TargetName="back"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Visibility" Value="Visible" TargetName="back"/>
                                <Setter Property="Background" Value="#EEE" TargetName="back"/>
                                <Setter Property="Foreground" Value="#AAA"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>


                    <SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
                    <SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
                    <SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>

                    <ControlTemplate TargetType="{x:Type TextBox}" x:Key="UserNameTextBoxTemplate">
                        <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" SnapsToDevicePixels="True"
                                CornerRadius="5">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="40"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="&#xe610;" FontFamily="../Assets/Fonts/#iconfont" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center"
                                           Foreground="#DDD"/>
                                <ScrollViewer x:Name="PART_ContentHost" Grid.Column="1" 
                                              Focusable="false" 
                                              HorizontalScrollBarVisibility="Hidden" 
                                              VerticalScrollBarVisibility="Hidden"
                                              VerticalAlignment="Center" MinHeight="20"/>
                            </Grid>

                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Opacity" TargetName="border" Value="0.56"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
                            </Trigger>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>

                    <ControlTemplate TargetType="{x:Type PasswordBox}" x:Key="PasswordBoxTemplate" >
                        <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" SnapsToDevicePixels="True"
                                CornerRadius="5">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="40"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="&#xe602;" FontFamily="../Assets/Fonts/#iconfont" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center"
                                           Foreground="#DDD"/>
                                <ScrollViewer x:Name="PART_ContentHost" Grid.Column="1" 
                                              Focusable="false" 
                                              HorizontalScrollBarVisibility="Hidden" 
                                              VerticalScrollBarVisibility="Hidden"
                                              VerticalAlignment="Center" MinHeight="20"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Opacity" TargetName="border" Value="0.56"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
                            </Trigger>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>

                    <ControlTemplate TargetType="{x:Type TextBox}" x:Key="VlidationCodeTextBoxTemplate">
                        <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" SnapsToDevicePixels="True"
                                CornerRadius="5">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="40"/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="80"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="&#xe64c;" FontFamily="../Assets/Fonts/#iconfont" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center"
                                           Foreground="#DDD"/>
                                <ScrollViewer x:Name="PART_ContentHost" Grid.Column="1" 
                                              Focusable="false" 
                                              HorizontalScrollBarVisibility="Hidden" 
                                              VerticalScrollBarVisibility="Hidden"
                                              VerticalAlignment="Center" MinHeight="20"/>
                                <Image Source="D:/validate_img.png" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Opacity="0.5"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Opacity" TargetName="border" Value="0.56"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
                            </Trigger>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Border Margin="5" Background="White" CornerRadius="10">
        <Border.Effect>
            <DropShadowEffect Color="Gray" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"/>
        </Border.Effect>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="2*"/>
                <RowDefinition Height="3*"/>
                <RowDefinition Height="100"/>
            </Grid.RowDefinitions>
            <Border Background="#007DFA" CornerRadius="10,10,0,0" MouseLeftButtonDown="WinMove_LeftButtonDown"/>
            <Button VerticalAlignment="Top" HorizontalAlignment="Right"
                    Style="{StaticResource WindowControlButtonStyle}" Content="&#xe653;"
                    Command="{Binding CloseWindowCommand}"
                    CommandParameter="{Binding ElementName=window}">
            </Button>

            <StackPanel VerticalAlignment="Bottom" Margin="0,0,0,30">
                <Border Width="80" Height="80" Background="White" VerticalAlignment="Center" HorizontalAlignment="Center"
                        CornerRadius="50"  Margin="0,0,0,20">
                    <Border.Effect>
                        <DropShadowEffect Color="White" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"/>
                    </Border.Effect>
                    <Border  Width="90" Height="80" HorizontalAlignment="Center">
                        <Border.Background>
                            <ImageBrush ImageSource="../Assets/Images/Logo.png"/>
                        </Border.Background>
                    </Border>
                </Border>
                <TextBlock Text="教育课程管理平台" HorizontalAlignment="Center" Foreground="White" FontSize="18"/>
            </StackPanel>

            <Grid Grid.Row="1" Margin="30,10" FocusManager.FocusedElement="{Binding ElementName=txtUserName}">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition MinHeight="23" Height="auto"/>
                </Grid.RowDefinitions>
                <TextBox Height="42" Text="{Binding LoginModel.UserName,UpdateSourceTrigger=PropertyChanged}" 
                         FontSize="16" Foreground="#555" Template="{StaticResource UserNameTextBoxTemplate}"
                         Name="txtUserName">
                    <TextBox.InputBindings>
                        <KeyBinding Key="Enter" Command="{Binding LoginCommand}"
                        CommandParameter="{Binding ElementName=window}"/>
                    </TextBox.InputBindings>
                </TextBox>
                <PasswordBox Grid.Row="1" Height="42" Template="{StaticResource PasswordBoxTemplate}"
                             FontSize="16" Foreground="#555"
                             common:PasswordHelper.Attach="True"
                             common:PasswordHelper.Password="{Binding LoginModel.Password,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
                    <PasswordBox.InputBindings>
                        <KeyBinding Key="Enter" Command="{Binding LoginCommand}"
                        CommandParameter="{Binding ElementName=window}"/>
                    </PasswordBox.InputBindings>
                </PasswordBox>
                <TextBox Grid.Row="2" Height="42" Template="{StaticResource VlidationCodeTextBoxTemplate}"
                         Text="{Binding LoginModel.ValidationCode,UpdateSourceTrigger=PropertyChanged}">
                    <TextBox.InputBindings>
                        <KeyBinding Key="Enter" Command="{Binding LoginCommand}"
                        CommandParameter="{Binding ElementName=window}"/>
                    </TextBox.InputBindings>
                </TextBox>
                <Button Content="登    录" Grid.Row="3" Height="42" Foreground="White" FontSize="16"
                        Template="{StaticResource LoginButtonTemplate}"
                        Command="{Binding LoginCommand}"
                        CommandParameter="{Binding ElementName=window}"/>
                <TextBlock Text="{Binding ErrorMessage}" Foreground="red" Grid.Row="4" FontSize="13" HorizontalAlignment="Center"
                           TextWrapping="Wrap" LineHeight="22" FontFamily="../Assets/Fonts/#iconfont"/>
            </Grid>

            <Grid Grid.Row="2" Margin="30,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="20"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition  Width="30"/>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Border BorderBrush="#DDD" BorderThickness="0,0,0,1" VerticalAlignment="Center"/>
                    <Border BorderBrush="#DDD" BorderThickness="0,0,0,1" VerticalAlignment="Center" Grid.Column="2"/>
                    <TextBlock Text="OR" Grid.Column="1" Foreground="#CCC" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                </Grid>
                <UniformGrid Columns="5" Grid.Row="1">
                    <UniformGrid.Resources>
                        <Style TargetType="TextBlock">
                            <Setter Property="Foreground" Value="#DDD"/>
                            <Setter Property="FontSize" Value="40"/>
                            <Setter Property="HorizontalAlignment" Value="Center"/>
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="FontFamily" Value="../Assets/Fonts/#iconfont"/>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Foreground" Value="#007DFA"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </UniformGrid.Resources>
                    <TextBlock Text="&#xe71c;"/>
                    <Border/>
                    <TextBlock Text="&#xe601;"/>
                    <Border/>
                    <TextBlock Text="&#xe60c;"/>
                </UniformGrid>
            </Grid>

            <Border Background="Transparent" Grid.Row="1" Grid.RowSpan="2"  Visibility="{Binding ShowProgress}">
                <ProgressBar VerticalAlignment="Top" Height="3" IsIndeterminate="True" Foreground="Orange"
                             Background="Transparent" BorderThickness="0"/>
            </Border>
        </Grid>
    </Border>
</Window>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

愚公搬代码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值