WPF登录窗体
开发工具与关键技术:WPF
作者:zhh
撰写时间:2021.1.8
WPF的窗体初始样式在现在的审美是比较简陋的,所以大部分要自定义窗体。如图:
页面构成
<Grid Background="#007DFA">
<Button VerticalAlignment="Top" HorizontalAlignment="Right" Width="40" Height="30"
Template="{StaticResource ColseButtonTempate}"></Button>
<Rectangle Fill="#fcfcfb" Opacity="0.3" Width="350" Height="180" RadiusX="5" RadiusY="5" Stroke="Gray" VerticalAlignment="Top" Margin="-290,65,-290,0"/>
<TextBlock Background="#eeeeee" Width="50" Height="30" VerticalAlignment="Top" Margin="-490,95,-290,0" Text="帐号" TextAlignment="Center" Padding="8"/>
<!--MaxLength属性:输入值的最大长度,不包含硬编码中Text的字符长度-->
<!--TextWrapping:如果设置成wrap ,就表示当文本长度超过容器长度时可以自动换行。
默认为no wrap,即当文本长度超过容器长度时,文本超出部分被遮挡。-->
<!--AcceptsReturn:允许回车换行操作-->
<TextBox Background="White" Width="200" Height="30" AcceptsReturn="True" MaxLength="20" TextWrapping="NoWrap" FontSize="16" Margin="50,-60,0,0" Padding="4"/>
<TextBlock Background="#eeeeee" Width="50" Height="30" VerticalAlignment="Top" Margin="-490,135,-290,0" Text="密码" TextAlignment="Center" Padding="8"/>
<PasswordBox Background="White" Width="200" Height="30" FontSize="16" Margin="50,20,0,0" MaxLength="20" Padding="4"></PasswordBox>
<!--Content:作用与TextBox的Text属性一样,但其数据类型为object,即可放任何对象,但只能存放一个对象-->
<Button Name="btn_Login" Style="{StaticResource NewButton}" Content="登录" Height="35" Width="70" FontSize="19" Cursor="Hand" Background="#DDD" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="130,180,0,0" FontFamily="Vivaldi"> </Button>
<!--Cursor:当光标进入控件范围时使用的鼠标指针-->
<Button Style="{StaticResource NewButton}" Height="35" Width="70" FontSize="15" Foreground="White" Background="#BBB" Content="退出" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="280,180,-290,0" Cursor="Hand" FontFamily="Vivaldi"/>
</Grid>