C# WPF开发可以仿照的多款登陆窗体,总有一个你喜欢

概述

    日常开发过程中,登陆窗体是我们经常会用到的,但是时常自己开发的登陆窗体有很丑陋,实际上我们常用的app每个都有登陆界面,有很多值得我们借鉴的漂亮登陆界面,我们只要参考一下,就很容易做出适合我们自己的。下面小编就展示十几款很常见的登陆界面截图,希望能帮到大家.同时文末展示一款我自己开发的登陆界面以及源码.

登陆窗体展示

款式1:腾讯会议

635836f6a7864e84b895b42311692cd9.png

款式二:百度网盘

54ad2542efc8c28c7b372d33e29180bb.png

款式三:金蝶云星空

f344c4b2c7763eb63f5ae78b158e531f.png

款式四:酷狗音乐

7734cefb71d2defa9532ebea7a6a10c9.png

款式五:12306

ef07183fcf041ab387bfb5eb232d6e45.png

款式六:easy connect

0d6b48f7e5dba27106492bb51d6ed02e.png

款式七:来源自网络

cd8c0c06e6b4da4739ebef03533e6691.png

款式八:摄图网

0ed2a457128277ac33a074b6d62ec762.png

款式九:知识管理协同办公平台

fd3d3d7d7bf41559ba9ec6d3417a7422.png

款式十:新榜官网

8f33dbe6874c0f820ecf0abb02b80fed.png

款式十一:知乎平台

78f7eb2f2dfb8a2fdf2fe8a77e384f0c.png

款式十一:博客园

1c0f484824f66b469f7048be281c5c2b.png

款式十二:csdn专业it技术社区

a4cc67f4d7b6380c985b3630093c4112.png

登陆界面开发

样式截图:

81e27a19e614a1088cef4ee47bbd9436.png

前台xaml代码:

<Window x:Class="AccountingSystem.Views.LoginView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        WindowStyle="None" AllowsTransparency="True" Background="{x:Null}" Foreground="Blue"
        Title="LoginWindow" Height="320" Width="300" WindowStartupLocation="CenterScreen">
    <!--<Window.Background>
        <ImageBrush ImageSource="/Images/loginimage.jpg"/>
    </Window.Background>-->
    <Grid  Width="{Binding Width, ElementName=w}" Height="{Binding Height, ElementName=w}">
        <Grid.RowDefinitions>
            <RowDefinition Height="150"/>
            <RowDefinition Height="50" />
            <RowDefinition Height="50" />
            <RowDefinition  />
        </Grid.RowDefinitions>
        <!--<Image Source="/Images/loginimage.jpg" Stretch="UniformToFill" Grid.RowSpan="4"/>-->
        <Border Grid.RowSpan="4" BorderBrush="Gray" BorderThickness="3" CornerRadius="20" Margin="10"  Opacity="1" Background="Thistle"></Border>
        <Button  Name="BtnClose"  Grid.Row="0" Margin="20" 
                 Width="48" Height="48"  BorderBrush="{x:Null}" Background="{x:Null}"
                 HorizontalAlignment="Right" VerticalAlignment="Top">
            <Image Source="/Images/exit1.png"/>
        </Button>
        <Image Grid.Row="0"  VerticalAlignment="Center" Width="120"  Height="120" Source="/Images/login.png" />


        <TextBox x:Name="UserTextBox" Text="{Binding UserInformation.UserName}"  Grid.Row="1"  Width="200" VerticalAlignment="Bottom" BorderThickness="0,0,0,1" Height="25"></TextBox>
        <TextBlock Foreground="DarkGray"  Grid.Row="1"  IsHitTestVisible="False" HorizontalAlignment="Center" Height="25" Text="请输入用户名" VerticalAlignment="Bottom" Width="90" FontFamily="Microsoft YaHei">
            <TextBlock.Style>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Text, ElementName=UserTextBox}" Value="">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
</Style>
            </TextBlock.Style>
        </TextBlock>
        <dxe:PasswordBoxEdit  x:Name="PwdTextBox" Text="{Binding UserInformation.Password}"  
                              Grid.Row="2"  Width="200" 
                              VerticalAlignment="Bottom" BorderThickness="0,0,0,1" Height="25"></dxe:PasswordBoxEdit>
        <TextBlock Foreground="DarkGray" Grid.Row="2"  IsHitTestVisible="False" HorizontalAlignment="Center" Height="25" Text="请输入密码" VerticalAlignment="Bottom" Width="90" FontFamily="Microsoft YaHei">
            <TextBlock.Style>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="Visibility" Value="Collapsed"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Text, ElementName=PwdTextBox}" Value="">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                    </Style.Triggers>
</Style>
            </TextBlock.Style>
        </TextBlock>


        <Button Name="BtnLogin"  Grid.Row="2"  Width="48" Margin="10,10,10,0"
                BorderBrush="{x:Null}" Background="{x:Null}" 
                Height="48"   HorizontalAlignment="Right" VerticalAlignment="Top" >
            <Image Source="/Images/userlogin.png"/>
        </Button>
    </Grid>
</Window>

后台代码:

using AccountingSystem.Models;
using Caliburn.Micro;
using PropertyChanged;
using System.Text;
using System.Windows;


namespace AccountingSystem.ViewModels
{
    [AddINotifyPropertyChangedInterface]
    public class LoginViewModel :Screen
    {
        private static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("LoginViewModel");
        public UserInformation UserInformation { get; set; }
        public LoginViewModel()
        {
            loginfo.Debug($"Enter [LoginViewModel].");
            UserInformation = new UserInformation();
            loginfo.Debug($"Leave [LoginViewModel].");
        }
        public void BtnLogin()
        {
            var str = ValidateLoginData();
            if(!string.IsNullOrEmpty(str))
            {
                MessageBox.Show(str);
 
            }
            else 
            {
                var loginWindow = (Window)this.GetView();
                loginWindow.Hide();


                var mainWindowViewModel = IoC.Get<MainWindowViewModel>();
                IWindowManager windowManager = IoC.Get<IWindowManager>();
                windowManager.ShowDialogAsync(mainWindowViewModel);
                this.TryCloseAsync();
            }


        }


       
        public void BtnClose()
        {
            this.TryCloseAsync();
        }


        public string ValidateLoginData()
        {
            StringBuilder sb = new StringBuilder();
            if (UserInformation.UserName == "zls20210502"
                    && UserInformation.Password == "12345678")
            {
                sb.Append("");
            }
            else
            {
                sb.AppendLine("账号或者密码输入有误,请检查!");
            }
            return sb.ToString();
        }
    }
}
技术群:添加小编微信并备注进群
小编微信:mm1552923   
公众号:Dotnet讲堂
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值