最近在作一個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