C# WPF实用的注册窗体

时间如流水,只能流去不流回!

点赞再看,养成习惯,这是您给我创作的动力!

本文 Dotnet9 https://dotnet9.com 已收录,站长乐于分享dotnet相关技术,比如Winform、WPF、ASP.NET Core等,亦有C++桌面相关的Qt Quick和Qt Widgets等,只分享自己熟悉的、自己会的。

阅读导航:

  • 一、先看效果
  • 二、本文背景
  • 三、代码实现
  • 四、文章参考
  • 五、代码下载

一、先看效果

C# WPF实用的注册窗体

二、本文背景

无。

三、代码实现

站长使用.Net Core 3.1创建的WPF工程,创建名称为“Register”的解决方案后,需要添加Nuget库,下面两个库都需要添加:

C# WPF实用的注册窗体

App.xaml添加MaterialDesign的样式文件

<Application.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.Purple.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

注册窗体MainWindow.xaml

<Window x:Class="Register.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:Register"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        mc:Ignorable="d"
        Title="MainWindow" Height="600" Width="1000">
    <Grid Background="#FFDADADA">
        <Border Margin="15" MaxWidth="600" Background="White" VerticalAlignment="Center" Padding="30" CornerRadius="15">
            <Border.Effect>
                <DropShadowEffect BlurRadius="30" Color="LightGray" ShadowDepth="0"/>
            </Border.Effect>
            <StackPanel>
                <TextBlock Text="欢迎" FontSize="30" FontWeight="Bold" Margin="0 0 0 20"/>

                <Grid Margin="0 0 0 20">
                    <Button Content="注册" HorizontalAlignment="Left"/>
                    <Button Content="登录" HorizontalAlignment="Right" Style="{StaticResource MaterialDesignFlatButton}"/>
                </Grid>

                <TextBox materialDesign:HintAssist.Hint="用户名" Style="{StaticResource MaterialDesignFloatingHintTextBox}" Margin="0 5"/>
                <PasswordBox materialDesign:HintAssist.Hint="密码" Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" Margin="0 5"/>
                <PasswordBox materialDesign:HintAssist.Hint="确认密码" Style="{StaticResource MaterialDesignFloatingHintPasswordBox}" Margin="0 5"/>
                <TextBox materialDesign:HintAssist.Hint="电子邮件" Style="{StaticResource MaterialDesignFloatingHintTextBox}" Margin="0 5"/>
                <Button Content="注册" Margin="0 20"/>
            </StackPanel>
        </Border>
    </Grid>
</Window>

四、文章参考

参考:
Design com WPF :   https://www.youtube.com/watch?v=B1azT_aRdHU&t=190s

五、代码下载

文章中代码已经全部贴出,就这么几行代码,不要奇怪,就是这么多。

 

除非注明,文章均由 Dotnet9 整理发布,欢迎转载。

转载请注明本文地址:https://dotnet9.com/2019/12/it-technology/csharp/wpf/register-window.html

欢迎扫描下方二维码关注 Dotnet9 的微信公众号,本站会及时推送最新技术文章(微信公众号“dotnet9_com”):

微信搜索公众号“dotnet9_com”添加关注

 

如有收获,请大力转发,给Dotnet9赞助和支持,谢谢大家对dotnet技术的关注和支持 。

本站使用 wpcom 的 JustNews主题

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值