我正在WPF中创建一个应用程序,我想要圆角。收到。既然窗体已经是无边界的了,我试图创建一个圆角矩形并将其放在顶部,以使其看起来像Windows应用程序的顶部栏。
我无法这样做。
这是我的代码:
<Border CornerRadius="50, 0, 50, 0" BorderBrush="Black" BorderThickness="2" Background="GhostWhite">
<Grid Margin="0,0,0,402">
<Rectangle HorizontalAlignment="Left" Height="44" VerticalAlignment="Top" Width="796">
<Rectangle.Fill>
<VisualBrush Stretch="None">
<VisualBrush.Visual>
<Border Width="800" Height="200" CornerRadius="50,0,0,0" Background="DarkOliveGreen"/>
</VisualBrush.Visual>
</VisualBrush>
</Rectangle.Fill>
</Rectangle>
<Grid HorizontalAlignment="Left" Height="403" Margin="0,44,0,-403" VerticalAlignment="Top" Width="796"/>
</Grid>
</Border>
Run Code Online (Sandbox Code Playgroud)
我的主要形式:
我得到的是:
经过测试并工作。
<Window
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:Controls="clr-namespace:WpfTester.Controls" x:Class="WpfTester.MainWindow"
mc:Ignorable="d"
WindowStyle="None"
AllowsTransparency="True"
Title="MainWindow" Height="1000" Width="1000" Loaded="Window_Loaded" MouseDown="Window_MouseDown">
<Window.Background>
<SolidColorBrush Opacity="0.0" Color="White"/>
</Window.Background>
<Grid Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition />
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Border CornerRadius="50, 0, 0, 0" BorderBrush="Black" BorderThickness="2,2,2,0" Background="DarkOliveGreen">
</Border>
</Grid>
<Border Grid.Row="1" BorderBrush="Black" BorderThickness="2,0,2,0" Background="White">
<Grid Name="Body">
</Grid>
</Border>
<Border Grid.Row="2" CornerRadius="0, 0, 50, 0" BorderBrush="Black" BorderThickness="2,0,2,2" Background="White">
</Border>
</Grid>
Run Code Online (Sandbox Code Playgroud)
您可以在名为“Body”的内容上添加您的内容
添加:更改了我的解决方案,因为背景:圆形边缘上的白色区域。
| 归档时间: |
|
| 查看次数: |
196 次 |
| 最近记录: |