IXamlSourceTransparency.IsBackgroundTransparent 属性

定义

命名空间:Windows.UI.Xaml

获取或设置一个值,该值指定当前线程上所有 DesktopWindowXamlSource 对象的背景是否透明。

[uuid(06636c29-5a17-458d-8ea2-2422d997a922)]
interface IXamlSourceTransparency
{
    Boolean IsBackgroundTransparent;
};

属性值

布尔值

true 如果窗口背景透明,则为 ;否则,为 false.

Windows 要求

设备系列Windows 10 (10.0.17763.0 中引入)

示例

此示例显示配置为具有透明背景的 DesktopWindowXamlSource 对象。

// Make all DesktopWindowXamlSource objects on this
// thread have a transparent background.
var xamlSourceTransparency = (IXamlSourceTransparency)Window.Current;
xamlSourceTransparency.IsBackgroundTransparent = true;

true设置为IsBackgroundTransparent如果以下内容设置为岛的内容,则第一列将显示主机的内容,但第二列将为白色。

<Grid ColumnDefinitions="Auto,*">
    <TextBlock>Column 0 text</TextBlock>

    <Border Grid.Column="1" Background="White">
        <TextBlock>Column 1 text</TextBlock>
    </Border>
</Grid>

备注

DesktopWindowXamlSource 类用于在另一个应用中托管 Xaml。 例如,可以使用此功能在 WPF 或 WinForms 应用中托管一些 Xaml 内容。 有关详细信息,请参阅 桌面应用(XAML 岛) 中的主机 WinRT XAML 控件。

默认情况下,XAML 内容具有不透明的背景,这意味着不可能让 XAML 显示之后的任何主机内容。 (在 WinUI3 中,此行为已更改;XAML 始终具有透明背景。

将此属性设置为 true 为当前线程上的所有 DesktopWindowXamlSource 对象提供透明背景。

从 XAML 窗口检索此接口。

注意

将此属性设置为 true XAML UWP 应用中将导致 XAML 窗口在全屏模式下(调用 ApplicationView.TryEnterFullScreenMode)透明。