将具有透明背景的用户控件添加到 Window

Adding a Usercontrol with a transparent Background to a Window

我创建了一个带有圆边边框的用户控件作为第一个真实元素。实际背景是透明的。

<UserControl
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:QP_WPF" x:Class="GUI_WPF_Interior"
         xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
         xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes;assembly=Xceed.Wpf.Toolkit"
mc:Ignorable="d" 
            DataContext="{Binding RelativeSource={RelativeSource Self}}"
         d:DesignWidth="600
" Background="transparent">
<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="ColorsAndBrushes.xaml" />
            <ResourceDictionary Source="ControlTemplates.xaml"/>
        </ResourceDictionary.MergedDictionaries>
</UserControl.Resources>
<Border  Margin="10" Background="{StaticResource BG_GradientBrush_2}" CornerRadius="12,12,12,12">
....

(边距只是为了更好地展示问题)

现在我想在 window 中显示此 UserControl。但是边距和圆边使用的区域保持白色。

<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:qp="clr-namespace:QP_WPF;assembly=QP_WPF"
Title="MainWindow" Height="680" Width="600"
WindowStyle="None"    
AllowsTransparency="True"
MouseLeftButtonDown="Window_MouseLeftButtonDown">
    <Grid Background="Transparent">
        <qp:GUI_WPF_Interior x:Name="GUIInterior" Background="Transparent"/>
    </Grid> 
</Window>

我需要做什么才能让 Window 只显示不透明的我的 UserControls 部分?

除了 AllowTransparency

之外,还尝试将 background=transparent 添加到 window