WPF 之佈局參考:登入視窗 01
阿新 • • 發佈:2021-01-13
▪ 佈局效果
▪ 佈局程式碼
<Window [...] Width="400" Height="240" WindowStyle="None" AllowsTransparency="True" ShowInTaskbar="False" Background="#00FFFFFF" WindowStartupLocation="CenterScreen" Topmost="True"> <Border CornerRadius="10,10,10,10" Background="#99000000"> <StackPanel Margin="20,20,20,20"> <TextBlock Height="60" Foreground="#FFFFFFFF" FontSize="30" HorizontalAlignment="Center">科德 ▪ 協同辦公系統</TextBlock> <WrapPanel Height="35" Margin="0,0,0,15" Background="#FFFFFFFF"> <Label Width="70" Height="35" VerticalContentAlignment="Center" HorizontalContentAlignment="Center">賬號:</Label> <TextBox VerticalContentAlignment="Center" Height="35" Width="290" BorderBrush="{x:Null}">12</TextBox> </WrapPanel> <WrapPanel Height="35" Margin="0,0,0,15" Background="#FFFFFFFF"> <Label Width="70" Height="35" VerticalContentAlignment="Center" HorizontalContentAlignment="Center">密碼:</Label> <PasswordBox VerticalContentAlignment="Center" Height="35" Width="290" BorderBrush="{x:Null}"></PasswordBox> </WrapPanel> <Button Height="35">登入</Button> </StackPanel> </Border> </Window>
▪ 程式碼說明
視窗背景透明
WindowStyle="None" AllowsTransparency="True" ShowInTaskbar="False" Background="#00FFFFFF"
視窗居中顯示
WindowStartupLocation="CenterScreen"
視窗置頂顯示
Topmost="True"
視窗背景黑色半透明並圓角
<Border CornerRadius="10,10,10,10" Background="#99000000">[...]</Border>