被子栅格截断的边框圆角半径

Corner radius of border cut off by child grid

提问人:pfinferno 提问时间:8/21/2023 更新时间:8/21/2023 访问量:30

问:

我有一个窗口,它有.我想让它里面有圆角。但是,只有右下角显示圆角,而其余部分似乎被边框内的内容截断。例如:WindowStyle="None"Border

<Window
    x:Class="SampleApp.MainWindow"
    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"
    AllowsTransparency="True"
    Background="Transparent"
    WindowStyle="None"
    mc:Ignorable="d">
    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="0" ResizeBorderThickness="5" />
    </WindowChrome.WindowChrome>
    <Border
        x:Name="WindowBorder"
        Background="{DynamicResource WindowBackgroundColor}"
        BorderBrush="Black"
        BorderThickness="1"
        CornerRadius="10">
        <Grid>
            <!-- Main Content -->
        </Grid>
    </Border>
</Window>

在右下角,它看起来像这样:enter image description here

其他角被切断,如下所示:enter image description here enter image description here

WPF XAML 半径无边框

评论

1赞 Legkov Ivan 8/21/2023
尝试将外边框设置为与 相同的值(但将其设置为 5 甚至 3 似乎也适用于 10,至少在我的测试应用程序中是这样)。这将防止网格中的内容与圆角重叠,并确保这种交互不会导致意外行为PaddingCornerRadiusCornerRadius
1赞 Legkov Ivan 8/21/2023
此外,如果填充不是一个选项,请考虑以下相关的 SO 答案

答: 暂无答案