当前位置: 首页 > news >正文

WPF-一个简单登录界面

一个简单登录界面


文章目录

  • 一个简单登录界面
    • 一、效果展示
    • 二、准备代码


一、效果展示

在这里插入图片描述

二、准备代码

创建一个WPF工程,创建名为 Login5 的WPF项目。
在这里插入图片描述
添加Nuget包

MaterialDesignThemes

界面的整体布局和样式代码

<Window x:Class="Login5.MainWindow"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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"xmlns:local="clr-namespace:Login5"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"ResizeMode="NoResize" WindowStartupLocation="CenterScreen"WindowStyle="None"><Window.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml"/><ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" /><ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Red.xaml" /><ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" /></ResourceDictionary.MergedDictionaries></ResourceDictionary></Window.Resources><Grid MouseDown="Grid_MouseDown"><Grid.Background><LinearGradientBrush StartPoint="0.1,0" EndPoint="0.9,1"><GradientStop Offset="1" Color="#FFE63070"/><GradientStop Offset="0" Color="#FFFE8704"/></LinearGradientBrush></Grid.Background><Border Height="390" VerticalAlignment="Top" Background="#100E17" CornerRadius="0 0 180 0"><StackPanel Orientation="Horizontal"><StackPanel Width="350"><Image Width="300" Height="300" Margin="30" VerticalAlignment="Top" Stretch="Fill" Source="pack://application:,,,/Login5;component/Images/left.png"/></StackPanel><StackPanel Width="350"><StackPanel Margin="20,40"><TextBlock Margin="20" FontFamily="Great Vibes"FontSize="38" Foreground="White" TextAlignment="Center">用户登录</TextBlock><StackPanel Margin="10" Orientation="Horizontal"><materialDesign:PackIconWidth="25" Height="25" Foreground="White"Kind="User"/><TextBox x:Name="txtUserName" Width="250"Margin="10,0" BorderBrush="White"CaretBrush="#FFD94448" Foreground="White"SelectionBrush="#FFD94448"materialDesign:HintAssist.Hint="输入 用户名 / 邮箱"/></StackPanel><StackPanel Margin="10" Orientation="Horizontal"><materialDesign:PackIconWidth="25" Height="25" Foreground="White"Kind="Lock"/><PasswordBox x:Name="txtPassword" Width="250"Margin="10,0" BorderBrush="White"CaretBrush="#FFD94448" Foreground="White"SelectionBrush="#FFD94448"materialDesign:HintAssist.Hint="********"/></StackPanel><StackPanel Margin="10" HorizontalAlignment="Center"><Button  x:Name="btnLogin" Width="100" Height="40"materialDesign:ButtonAssist.CornerRadius="10"Background="#D94448" BorderBrush="#D94448" BorderThickness="2"Content="登录" Foreground="White" ToolTip="登录"Style="{StaticResource MaterialDesignRaisedButton}"/></StackPanel></StackPanel></StackPanel><StackPanel Width="100"><Button x:Name="btnExit" Margin="10,20" Background="{x:Null}"Click="btnExit_Click" Style="{StaticResource MaterialDesignFloatingActionButton}"ToolTip="关闭"><materialDesign:PackIcon Width="30" Height="30" Foreground="White" Kind="Close"/></Button></StackPanel></StackPanel></Border></Grid>
</Window>

MainWindow.xaml.cs

using System.Windows;
using System.Windows.Input;namespace Login5
{/// <summary>/// Interaction logic for MainWindow.xaml/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();}private void btnExit_Click(object sender, RoutedEventArgs e){this.Close();}private void Grid_MouseDown(object sender, MouseButtonEventArgs e){if(Mouse.LeftButton == MouseButtonState.Pressed){this.DragMove();}}}
}

相关文章:

  • 跨境电商如何利用跨境客服软件提升销售额
  • 使用FiscoBcos的Go-SDK【1:配置go环境】
  • hive数据仓库工具
  • 华为数通---配置基本QinQ示例
  • 物联网在能源管理中的应用——青创智通工业物联网解决方案
  • js 原型 和 原型链
  • 【ProcessOn】流程图咏道图Axure自定义元件使用----含流程图案例
  • 【delphi11】delphi基础探索【二、 Delphi 的基本语法:变量声明、数据类型、控制语句】
  • 深入解析Freemarker模板引擎及其在Spring Boot中的高级整合
  • 鸿蒙开发之页面与组件生命周期
  • Unity_ET框架项目-斗地主_启动运行流程
  • 大数据技术8:StarRocks极速全场景MPP数据库
  • Bootstrap Blazor中的富文本编辑器(Editor)如何禁用?
  • 【Java系列】详解多线程(二)——Thread类及常见方法(上篇)
  • 【网络通信原理之套接字】
  • 《微软的软件测试之道》成书始末、出版宣告、补充致谢名单及相关信息
  • co.js - 让异步代码同步化
  • ERLANG 网工修炼笔记 ---- UDP
  • es6--symbol
  • Java编程基础24——递归练习
  • Java读取Properties文件的六种方法
  • jquery ajax学习笔记
  • js学习笔记
  • k8s如何管理Pod
  • leetcode378. Kth Smallest Element in a Sorted Matrix
  • NSTimer学习笔记
  • overflow: hidden IE7无效
  • Rancher-k8s加速安装文档
  • Vue.js-Day01
  • Vue学习第二天
  • XForms - 更强大的Form
  • 程序员最讨厌的9句话,你可有补充?
  • 动态规划入门(以爬楼梯为例)
  • 干货 | 以太坊Mist负责人教你建立无服务器应用
  • 简单实现一个textarea自适应高度
  • 容器服务kubernetes弹性伸缩高级用法
  • 如何抓住下一波零售风口?看RPA玩转零售自动化
  • 带你开发类似Pokemon Go的AR游戏
  • ​Base64转换成图片,android studio build乱码,找不到okio.ByteString接腾讯人脸识别
  • ​二进制运算符:(与运算)、|(或运算)、~(取反运算)、^(异或运算)、位移运算符​
  • # include “ “ 和 # include < >两者的区别
  • ()、[]、{}、(())、[[]]命令替换
  • (2.2w字)前端单元测试之Jest详解篇
  • (26)4.7 字符函数和字符串函数
  • (译)2019年前端性能优化清单 — 下篇
  • (原創) 如何解决make kernel时『clock skew detected』的warning? (OS) (Linux)
  • .net Application的目录
  • .NET C# 使用 SetWindowsHookEx 监听鼠标或键盘消息以及此方法的坑
  • .net core 6 集成 elasticsearch 并 使用分词器
  • .net 调用php,php 调用.net com组件 --
  • .NET 中 GetHashCode 的哈希值有多大概率会相同(哈希碰撞)
  • /ThinkPHP/Library/Think/Storage/Driver/File.class.php  LINE: 48
  • @RunWith注解作用
  • [.net 面向对象程序设计进阶] (19) 异步(Asynchronous) 使用异步创建快速响应和可伸缩性的应用程序...
  • [autojs]autojs开关按钮的简单使用