当前位置:网站首页>WPF项目入门1-简单登录页面的设计和开发
WPF项目入门1-简单登录页面的设计和开发
2022-07-25 11:31:00 【济南医疗小程序状元】
先看效果

上代码
1 默认启动页面代码
<Application x:Class="WpfApp2.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp2"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

2 前端布局,设置,控件使用,和按钮双击,添加事件代码
<Window x:Class="WpfApp2.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:local="clr-namespace:WpfApp2"
mc:Ignorable="d"
Title="登录页面" Height="294.5" Width="374.5" ShowInTaskbar="False"
WindowStartupLocation="CenterScreen" WindowState="Maximized" Topmost="True" Icon="Imgs/logoyun.png"
>
<!--网格类型的 行和列 布局控件 Grid Window的Content 内容 -->
<Grid Margin="0,0,-91,-67">
<!--Content属性设置文本内容 1 Content="登录" 设置文本值内容的2种方式,2 写在文本之间。3 label控件写入方式 实现 -->
<Button Name="btnLogin" HorizontalAlignment="Left" Margin="104,172,0,0" VerticalAlignment="Top"
Width="50" Content="登录" Click="btnLogin_Click">
<!--<Label Content="登录" HorizontalAlignment="Left" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-0.464"/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>-->
</Button>
<Label Name="lbluName" Content="账号:" HorizontalAlignment="Left"
Margin="93,88,0,0" VerticalAlignment="Top" Width="108"/>
<TextBox Name="txtUName" HorizontalAlignment="Left" Height="23" Margin="139,90,0,0"
TextWrapping="NoWrap"
Text="admin" VerticalAlignment="Top" Width="120"/>
<Label Content="密码:" HorizontalAlignment="Left"
Margin="93,118,0,0" VerticalAlignment="Top" Width="108"/>
<PasswordBox Name="txtUPwd" HorizontalAlignment="Left" Height="23" Margin="139,122,0,0"
Password="123456" PasswordChar="*" VerticalAlignment="Top" Width="120"/>
<Button Name="btnConcel"
Content="取消" HorizontalAlignment="Left"
Margin="184,172,0,0" VerticalAlignment="Top" Width="50"
Click="BtnCancel_Click"/>
</Grid>
<!--根节点 window-->
</Window>
3 C#类代码,按钮事件的注册
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApp2
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, RoutedEventArgs e)
{
//控件的事件注册
}
private void BtnCancel_Click(object sender, RoutedEventArgs e)
{
}
}
}
启动效果

边栏推荐
- [high concurrency] Why is the simpledateformat class thread safe? (six solutions are attached, which are recommended for collection)
- keepalived实现mysql的高可用
- [untitled]
- Learning to pre train graph neural networks
- Zero-Shot Image Retrieval(零样本跨模态检索)
- 'C:\xampp\php\ext\php_ zip. Dll'-%1 is not a valid Win32 Application Solution
- php 一台服务器传图片到另一台上 curl post file_get_contents保存图片
- 和特朗普吃了顿饭后写下了这篇文章
- 【AI4Code】《Contrastive Code Representation Learning》 (EMNLP 2021)
- 【AI4Code】《GraphCodeBERT: Pre-Training Code Representations With DataFlow》 ICLR 2021
猜你喜欢

第一个scrapy爬虫

【微服务~Sentinel】Sentinel降级、限流、熔断

【GCN-RS】Are Graph Augmentations Necessary? Simple Graph Contrastive Learning for RS (SIGIR‘22)

Sword finger offer 22. the penultimate node in the linked list

【AI4Code】《Pythia: AI-assisted Code Completion System》(KDD 2019)

Brpc source code analysis (IV) -- bthread mechanism

【AI4Code】《IntelliCode Compose: Code Generation using Transformer》 ESEC/FSE 2020

2.1.2 机器学习的应用

【多模态】《HiT: Hierarchical Transformer with Momentum Contrast for Video-Text Retrieval》ICCV 2021

Brpc source code analysis (I) -- the main process of RPC service addition and server startup
随机推荐
【CTR】《Towards Universal Sequence Representation Learning for Recommender Systems》 (KDD‘22)
Go garbage collector Guide
Plus版SBOM:流水线物料清单PBOM
2.1.2 机器学习的应用
Data transmission under the same LAN based on tcp/ip
scrapy 设置随机的user_agent
How to solve the problem of the error reported by the Flink SQL client when connecting to MySQL?
记录一次线上死锁的定位分析
【AI4Code】《CodeBERT: A Pre-Trained Model for Programming and Natural Languages》 EMNLP 2020
LeetCode第303场周赛(20220724)
【图攻防】《Backdoor Attacks to Graph Neural Networks 》(SACMAT‘21)
Client open download, welcome to try
Power Bi -- these skills make the report more "compelling"“
苹果供应链十年浮沉:洋班主任和它的中国学生们
PHP uploads the FTP path file to the curl Base64 image on the Internet server
Ansible
Intelligent information retrieval (overview of intelligent information retrieval)
【Debias】Model-Agnostic Counterfactual Reasoning for Eliminating Popularity Bias in RS(KDD‘21)
I advise those students who have just joined the work: if you want to enter the big factory, you must master these concurrent programming knowledge! Complete learning route!! (recommended Collection)
Mirror Grid