|
| 1 | +--- |
| 2 | +title: IXamlSourceTransparency.IsBackgroundTransparent property |
| 3 | +description: Gets or sets the background transparency of all DesktopWindowXamlSource objects on the current thread. |
| 4 | +ms.topic: article |
| 5 | +ms.date: 07/28/2023 |
| 6 | +ms.author: jimwalk |
| 7 | +author: jwmsft |
| 8 | +ms.localizationpriority: low |
| 9 | +--- |
| 10 | + |
| 11 | +# IXamlSourceTransparency.IsBackgroundTransparent property |
| 12 | + |
| 13 | +## Definition |
| 14 | + |
| 15 | +Namespace: Windows.UI.Xaml |
| 16 | + |
| 17 | +Gets or sets a value that specifies whether the background of all DesktopWindowXamlSource objects on the current thread is transparent. |
| 18 | + |
| 19 | +```csharp |
| 20 | +[uuid(06636c29-5a17-458d-8ea2-2422d997a922)] |
| 21 | +interface IXamlSourceTransparency |
| 22 | +{ |
| 23 | + Boolean IsBackgroundTransparent; |
| 24 | +}; |
| 25 | +``` |
| 26 | + |
| 27 | +### Property Value |
| 28 | + |
| 29 | +[Boolean](/dotnet/api/system.boolean) |
| 30 | + |
| 31 | +`true` if the window background is transparent; otherwise, `false`. |
| 32 | + |
| 33 | +## Windows requirements |
| 34 | + |
| 35 | +<table><tr><td>Device family</td><td>Windows 10 (introduced in 10.0.17763.0)</td></tr></table> |
| 36 | + |
| 37 | +## Examples |
| 38 | + |
| 39 | +This example shows the [DesktopWindowXamlSource](/uwp/api/windows.ui.xaml.hosting.desktopwindowxamlsource) objects being configured to have a transparent background. |
| 40 | + |
| 41 | +```csharp |
| 42 | +// Make all DesktopWindowXamlSource objects on this |
| 43 | +// thread have a transparent background. |
| 44 | +var xamlSourceTransparency = (IXamlSourceTransparency)Window.Current; |
| 45 | +xamlSourceTransparency.IsBackgroundTransparent = true; |
| 46 | +``` |
| 47 | + |
| 48 | +With `IsBackgroundTransparent` set to `true`, if the following is set as the content of an island, the first column will show the content of the host but the second column will be white. |
| 49 | + |
| 50 | +```xaml |
| 51 | +<Grid ColumnDefinitions="Auto,*"> |
| 52 | + <TextBlock>Column 0 text</TextBlock> |
| 53 | + |
| 54 | + <Border Grid.Column="1" Background="White"> |
| 55 | + <TextBlock>Column 1 text</TextBlock> |
| 56 | + </Border> |
| 57 | +</Grid> |
| 58 | +``` |
| 59 | + |
| 60 | +## Remarks |
| 61 | + |
| 62 | +The [DesktopWindowXamlSource](/uwp/api/windows.ui.xaml.hosting.desktopwindowxamlsource) class is used to host Xaml in another app. For example, you can use this to host some Xaml content in a WPF or WinForms app. See [Host WinRT XAML controls in desktop apps (XAML Islands)](/windows/apps/desktop/modernize/xaml-islands) for more info. |
| 63 | + |
| 64 | +By default, the XAML content has an opaque background, meaning that it's not possible to have any of the host content behind the XAML show through. (In WinUI3, this behavior is changed; the XAML always has a transparent background.) |
| 65 | + |
| 66 | +Set this property to `true` to give all [DesktopWindowXamlSource](/uwp/api/windows.ui.xaml.hosting.desktopwindowxamlsource) objects on the current thread a transparent background. |
| 67 | + |
| 68 | +This interface is retrieved from a XAML [Window](/uwp/api/windows.ui.xaml.window). |
| 69 | + |
| 70 | +> [!NOTE] |
| 71 | +> Setting this property to `true` in a XAML UWP app will cause a XAML [Window](/uwp/api/Windows.UI.Xaml.Window) to be transparent as well when it's in full screen mode (when you've called [ApplicationView.TryEnterFullScreenMode](/uwp/api/Windows.UI.ViewManagement.ApplicationView.TryEnterFullScreenMode)). |
0 commit comments