WPF中做出一个QQ登陆界面
Xaml:
<Window x:Class="ChatSoftware.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:ChatSoftware" mc:Ignorable="d" Title="MainWindow" Height="603.659" Width="994.776"> <Window.Resources> <local:Number x:Key="Key_Number"/> <local:Fruits x:Key="Key_Fruits"/> </Window.Resources> <Grid HorizontalAlignment="Left" Height="560" Margin="10,10,0,0" VerticalAlignment="Top" Width="975"> <Grid.Background> <ImageBrush ImageSource="Resources/timg (3).jpg"/> </Grid.Background> <Grid.RowDefinitions> <RowDefinition Height="400"/> <RowDefinition/> </Grid.RowDefinitions> <StackPanel HorizontalAlignment="Left" Height="204" Margin="192,119,0,0" VerticalAlignment="Top" Width="601" Grid.Column="200"> <Grid Height="202" Background="Transparent" Margin="0,0,-100.2,0"> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition Height="50"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="200"/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Image HorizontalAlignment="Left" Height="135" Margin="36,36,0,0" Grid.RowSpan="3" VerticalAlignment="Top" Width="137" Source="Resources/2.jpg" RenderTransformOrigin="0.513,0.666" Stretch="Fill"/> <ComboBox Background="White" DataContext="{StaticResource Key_Number}" ItemsSource="{Binding Items, Source={StaticResource Key_Number}}" SelectedIndex="0" Grid.Column="1" HorizontalAlignment="Left" Margin="34,36,0,0" VerticalAlignment="Top" Width="301" Height="40" Grid.ColumnSpan="2" BorderBrush="#FFC0EBCB" IsEditable="True" FontSize="18"/> <CheckBox Content="记住密码" Grid.Column="1" HorizontalAlignment="Left" Margin="34,10,0,0" Grid.Row="2" VerticalAlignment="Top" Height="30" Width="115" FontSize="16" FontStyle="Oblique" Foreground="#FFD7C73B"/> <CheckBox Content="自动登陆" Grid.Column="2" HorizontalAlignment="Left" Margin="20.8,9.8,0,0" Grid.Row="2" VerticalAlignment="Top" Height="30" RenderTransformOrigin="0.438,1.063" FontSize="16" Foreground="#FF9174BF"/> <PasswordBox Grid.Column="1" MaxLength="15" HorizontalAlignment="Left" Margin="34,28,0,0" Grid.Row="1" VerticalAlignment="Top" Height="38" Grid.ColumnSpan="2" Width="301" FontSize="18"/> <TextBlock Grid.Column="2" HorizontalAlignment="Right" Margin="0,36,9.8,0" TextWrapping="Wrap" Text="" Width="122" Height="40" VerticalAlignment="Top" FontSize="18"> <Hyperlink NavigateUri="http://www.baidu.com" Click="Hyperlink_Click" >注册账号</Hyperlink> </TextBlock> </Grid> </StackPanel> <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="100" Margin="360,10,0,0" Grid.Row="1" VerticalAlignment="Top" Width="293" CornerRadius="20" Background="{DynamicResource {x:Static SystemColors.ActiveCaptionBrushKey}}"> <Button Background="Transparent" Content="登 陆" FontSize="36" Foreground="#FF264515" RenderTransformOrigin="0.477,0.058" Margin="-0.8,-0.8,-1,0" BorderBrush="Transparent"/> </Border> <TextBlock HorizontalAlignment="Left" Margin="764,219,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="36" Width="115" Foreground="#FFB8D60D" FontSize="18"> <Hyperlink NavigateUri="http://www.baidu.com" Click="Hyperlink_Click" >找回密码</Hyperlink> </TextBlock> </Grid> </Window>
后台:
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; using System.Diagnostics; namespace ChatSoftware { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Hyperlink_Click(object sender, RoutedEventArgs e) { Hyperlink link = sender as Hyperlink; Process.Start(new ProcessStartInfo(link.NavigateUri.AbsoluteUri)); } } }
Class(Number):
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ChatSoftware { public class Number { public Number() { Items = new List<string> { "1308531510", "2569875222", "5648999998", "2415645616", }; } public List<string> Items { get; set; } } }
效果图:
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· DeepSeek火爆全网,官网宕机?本地部署一个随便玩「LLM探索」
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 上周热点回顾(1.20-1.26)
· 【译】.NET 升级助手现在支持升级到集中式包管理