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

【1】WPF界面开发入门—— 图书馆程序:登录界面设计

文章目录

  • 1 C# wpf 创建工程
  • 2 添加界面代码 及运行效果
  • 3 重点代码解释

P11 图书馆程序:登录界面设计

1 C# wpf 创建工程

在这里插入图片描述
在这里插入图片描述

MainWindow.xaml 主界面如下
在这里插入图片描述

MainWindow.xaml 主界面 布局系统自带代码如下

<Window x:Class="WpfApp1.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:WpfApp1"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid></Grid>
</Window>

2 添加界面代码 及运行效果

我们需要在<Grid> </Grid> 之间天界主界面布局代码
我们的目标界面如下
在这里插入图片描述

我添加的代码如下

<Window x:Class="WpfApp1.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:WpfApp1"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="Auto"/><RowDefinition Height="1*"/><RowDefinition Height="9*"/><RowDefinition/></Grid.RowDefinitions><TextBlock Grid.Row="0" Grid.Column="0" Text="深圳大学图书馆"  FontSize="18" HorizontalAlignment="Center"/><StackPanel Margin="5"  Grid.Row="1" Background="#0078d4"><TextBlock Text="登录"  FontSize="22" HorizontalAlignment="Center" Foreground="White" /></StackPanel><Grid Grid.Row="3" HorizontalAlignment="Center"><Grid.RowDefinitions><RowDefinition Height="30"/><RowDefinition Height="30"/><RowDefinition Height="30"/><RowDefinition Height="30"/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition Width="Auto"/><ColumnDefinition Width="200"/></Grid.ColumnDefinitions><TextBlock Text="用户名" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"  FontSize="20"/><TextBox Grid.Row="0" Grid.Column="1" Margin="2"/><TextBlock Text="密码" Grid.Row="1" VerticalAlignment="Center" FontSize="20"/><TextBox Grid.Row="1" Grid.Column="1" Margin="2"/><CheckBox Content="记住密码"   Grid.Row="2" Grid.ColumnSpan="2"  VerticalAlignment="Center" FontSize="20"/><Button Content="登录" Grid.Row="3" Grid.ColumnSpan="2"  VerticalAlignment="Center" FontSize="20"/></Grid></Grid>
</Window>

在这里插入图片描述
在这里插入图片描述

3 重点代码解释

			//总高度的1/10,<RowDefinition Height="1*"/>//总高度的9/10分,<RowDefinition Height="9*"/>
//默认0列,所以Grid.Column="0"可以不写
<TextBlock Grid.Row="0" Grid.Column="0" Text="深圳大学图书馆"  FontSize="18" HorizontalAlignment="Center"/>//Margin="5" 与上一行间距5 , HorizontalAlignment="Center"水平居中,VerticalAlignment="Center"垂直居中
<StackPanel Margin="5"  Grid.Row="1" Background="#0078d4">
//Grid.ColumnSpan="2"  合并2列,默认从0列开始<CheckBox Content="记住密码"   Grid.Row="2" Grid.ColumnSpan="2"  VerticalAlignment="Center" FontSize="20"/>
http://www.dtcms.com/a/312668.html

相关文章:

  • 基于图像识别与分类的中国蛇类识别系统
  • [硬件电路-151]:数字电路 - 模拟电路与数字电路的本质
  • 【数据结构】二叉树的顺序结构实现
  • SQL注入SQLi-LABS 靶场less31-38详细通关攻略
  • 托福阅读38-3
  • 使用AssemblyAI将音频数据转换成文本
  • AI生成图片工具分享!
  • Linux的权限概念
  • 关于Web前端安全之XSS攻击防御增强方法
  • 【视频内容创作】PR的关键帧动画
  • 机器学习第三课之逻辑回归(三)LogisticRegression
  • Python-初学openCV——图像预处理(五)
  • 团队独立思考的力量
  • 论文阅读:DMD蒸馏 | One-step Diffusion with Distribution Matching Distillation
  • Python 动态属性和特性(定义一个特性工厂函数)
  • 「源力觉醒 创作者计划」_文心大模型4.5系列开源模型, 从一行代码到一个生态:聊聊开源战略那些事儿,顺便扯扯文心大模型 4.5 的使用心得
  • zookeeper分布式锁 -- 读锁和写锁实现方式
  • gpu instancer crowd 使用自定义材质并且只修改单个物体的材质参数
  • 【领域热点】【Vue】Vue 与 WebAssembly:前端性能优化的黄金搭档
  • 渗透高级-----应急响应
  • 机器翻译的分类:规则式、统计式、神经式MT的核心区别
  • 新电脑上GitHub推送失败?全面排查与解决指南
  • 第三章-提示词-高级:开启智能交互新境界(13/36)
  • Flutter Dart类的使用
  • WebMvc自动配置流程讲解
  • 【MySQL】MySQL的安全风险与安装安全风险
  • GraphRAG:基于知识图谱的检索增强生成技术解析
  • OSPF HCIP
  • RAG 中常见的文本分块(chunk)方法及实战代码示例
  • 基于开源AI智能客服、AI智能名片与S2B2C商城小程序的餐饮行业私域流量运营策略研究