C# WPF開發可以仿照的多款登陸窗體,總有一個你喜歡

2024年2月6日 18点热度 0人点赞

概述

日常開發過程中,登陸窗體是我們經常會用到的,但是時常自己開發的登陸窗體有很醜陋,實際上我們常用的app每個都有登陸界面,有很多值得我們借鑒的漂亮登陸界面,我們隻要參考一下,就很容易做出適合我們自己的。下面小編就展示十幾款很常見的登陸界面截圖,希望能幫到大傢.同時文末展示一款我自己開發的登陸界面以及源碼.

登陸窗體展示

款式1:騰訊會議

款式二:百度網盤

款式三:金蝶雲星空

款式四:酷狗音樂

款式五:12306

款式六:easy connect

款式七:來源自網絡

款式八:攝圖網

款式九:知識管理協同辦公平臺

款式十:新榜官網

款式十一:知乎平臺

款式十一:博客園

款式十二:csdn專業it技術社區

登陸界面開發

樣式截圖:

前臺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:}" 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:}" Background="{x:}" 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:}" Background="{x:}" 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.IsOrEmpty(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講堂