最近在作一个UWP项目,登陆的用户和密码框须要圆角的,因为UWP的TextBlock 和PasswordBox是没有CornerRadius属性的,因而我就使用了一个Border嵌套在最外层,设置其余CornerRadius="20"spa
实现代码以下:code
<!--帐号--> <Border Background="#FFFFFF" CornerRadius="20"> <RelativePanel Margin="10,0,0,0" Padding="5"> <TextBlock x:Name="tbNumber" Text="帐号:" RelativePanel.AlignVerticalCenterWithPanel="True" /> <TextBox x:Name="txtUserName" FontSize="16" RelativePanel.RightOf="tbNumber" PlaceholderText="请输入GW号/手机号" RelativePanel.AlignRightWithPanel="True" RelativePanel.AlignHorizontalCenterWithPanel="True" RelativePanel.AlignVerticalCenterWithPanel="True" Margin="0,5,0,0" BorderThickness="0" InputScope="NameOrPhoneNumber"/> </RelativePanel> </Border> <!--密码--> <Border Background="#FFFFFF" CornerRadius="20" Margin="0,20,0,0"> <RelativePanel Margin="10,0,0,0" Padding="5"> <TextBlock x:Name="tbPwd" Text="密码:" RelativePanel.AlignVerticalCenterWithPanel="True" /> <PasswordBox x:Name="txtPwd" RelativePanel.RightOf="tbPwd" PlaceholderText="请输入密码" RelativePanel.AlignRightWithPanel="True" IsEnabled="True" BorderThickness="0" RelativePanel.AlignHorizontalCenterWithPanel="True" RelativePanel.AlignVerticalCenterWithPanel="True" Margin="0,5,0,0"/> </RelativePanel> </Border>
效果图以下:blog
UWP小白一个,欢迎指教!!it