Jaa


AcrylicBrush Class

Definition

Paints an area with a semi-transparent material that uses multiple effects including blur and a noise texture.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[WebHostHidden]
class AcrylicBrush : XamlCompositionBrushBase
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class AcrylicBrush : XamlCompositionBrushBase
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class AcrylicBrush : XamlCompositionBrushBase
function AcrylicBrush()
Public Class AcrylicBrush
Inherits XamlCompositionBrushBase
Inheritance
Attributes

Windows requirements

Device family
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v5.0)

Examples

Tip

For more info, design guidance, and code examples, see Acrylic material.

If you have the WinUI 2 Gallery app installed, click here to open the app and see Acrylic in action.

To add an acrylic brush, define the three resources for dark, light and high contrast themes. Note that in high contrast, we recommend using a SolidColorBrush with the same x:Key as the dark/light AcrylicBrush.

Note

If you don't specify a TintLuminosityOpacity value, the system will automatically adjust its value based on your TintColor and TintOpacity.

<ResourceDictionary.ThemeDictionaries>
    <ResourceDictionary x:Key="Default">
        <AcrylicBrush x:Key="MyAcrylicBrush"
            BackgroundSource="HostBackdrop"
            TintColor="#FFFF0000"
            TintOpacity="0.8"
            TintLuminosityOpacity="0.5"
            FallbackColor="#FF7F0000"/>
    </ResourceDictionary>

    <ResourceDictionary x:Key="HighContrast">
        <SolidColorBrush x:Key="MyAcrylicBrush"
            Color="{ThemeResource SystemColorWindowColor}"/>
    </ResourceDictionary>

    <ResourceDictionary x:Key="Light">
        <AcrylicBrush x:Key="MyAcrylicBrush"
            BackgroundSource="HostBackdrop"
            TintColor="#FFFF0000"
            TintOpacity="0.8"
            TintLuminosityOpacity="0.5"
            FallbackColor="#FFFF7F7F"/>
    </ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

This example shows how to create an AcrylicBrush in code. If your app supports multiple OS targets, be sure to check that this API is available on the user’s machine before you use it.

if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush"))
{
    Windows.UI.Xaml.Media.AcrylicBrush myBrush = new Windows.UI.Xaml.Media.AcrylicBrush();
    myBrush.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop;
    myBrush.TintColor = Color.FromArgb(255, 202, 24, 37);
    myBrush.FallbackColor = Color.FromArgb(255, 202, 24, 37);
    myBrush.TintOpacity = 0.6;

    grid.Fill = myBrush;
}
else
{
    SolidColorBrush myBrush = new SolidColorBrush(Color.FromArgb(255, 202, 24, 37));

    grid.Fill = myBrush;
}

Remarks

Version history

Windows version SDK version Value added
1903 18362 TintLuminosityOpacity

Constructors

AcrylicBrush()

Initializes a new instance of the AcrylicBrush class.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.-ctor (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

Properties

AlwaysUseFallback

Gets or sets a value that specifies whether the brush is forced to the solid fallback color.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.AlwaysUseFallback (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

AlwaysUseFallbackProperty

Identifies the AlwaysUseFallback dependency property.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.AlwaysUseFallbackProperty (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

BackgroundSource

Gets or sets a value that specifies whether the brush samples from the app content or from the content behind the app window.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.BackgroundSource (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

BackgroundSourceProperty

Identifies the BackgroundSource dependency property.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.BackgroundSourceProperty (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

CompositionBrush

Gets or sets the CompositionBrush used by this XAML brush.

(Inherited from XamlCompositionBrushBase)
Dispatcher

Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread.

(Inherited from DependencyObject)
FallbackColor

The color to use for rendering in case the CompositionBrush can't be rendered.

(Inherited from XamlCompositionBrushBase)
Opacity

Gets or sets the degree of opacity of a Brush.

(Inherited from Brush)
RelativeTransform

Gets or sets the transformation that is applied to the brush using relative coordinates.

(Inherited from Brush)
TintColor

Gets or sets the color tint for the semi-transparent acrylic material.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.TintColor (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

TintColorProperty

Identifies the TintColor dependency property.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.TintColorProperty (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

TintLuminosityOpacity

Gets or sets the brightness amount between the TintColor and the underlying pixels behind the Acrylic surface.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.TintLuminosityOpacity (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

TintLuminosityOpacityProperty

Identifies the TintLuminosityOpacity dependency property.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.TintLuminosityOpacityProperty (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

TintOpacity

Gets or sets the degree of opacity of the color tint.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.TintOpacity (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

TintOpacityProperty

Identifies the TintOpacity dependency property.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.TintOpacityProperty (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

TintTransitionDuration

Gets or sets the length of the automatic transition animation used when the TintColor changes.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.TintTransitionDuration (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

TintTransitionDurationProperty

Identifies the TintTransitionDuration dependency property.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Media.AcrylicBrush.TintTransitionDurationProperty (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

Transform

Gets or sets the transformation that is applied to the brush.

(Inherited from Brush)

Methods

ClearValue(DependencyProperty)

Clears the local value of a dependency property.

(Inherited from DependencyObject)
GetAnimationBaseValue(DependencyProperty)

Returns any base value established for a dependency property, which would apply in cases where an animation is not active.

(Inherited from DependencyObject)
GetValue(DependencyProperty)

Returns the current effective value of a dependency property from a DependencyObject.

(Inherited from DependencyObject)
OnConnected()

Invoked when a brush is first used on screen to paint an element.

When implemented in a derived class, you can create a CompositionBrush instance and provide it to the framework by setting the CompositionBrush property.

OnDisconnected will be called when the brush is no longer being used to paint any elements.

(Inherited from XamlCompositionBrushBase)
OnDisconnected()

Invoked when the brush is no longer being used to paint any elements.

When implemented in a derived class, you can safely dispose of the compostion brush and other composition resources.

OnConnected will be called again if the brush is later used to paint any elements after being disconnected.

(Inherited from XamlCompositionBrushBase)
PopulatePropertyInfo(String, AnimationPropertyInfo)

Defines a property that can be animated.

(Inherited from Brush)
PopulatePropertyInfoOverride(String, AnimationPropertyInfo)

When overridden in a derived class, defines a property that can be animated.

(Inherited from Brush)
ReadLocalValue(DependencyProperty)

Returns the local value of a dependency property, if a local value is set.

(Inherited from DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance.

(Inherited from DependencyObject)
SetValue(DependencyProperty, Object)

Sets the local value of a dependency property on a DependencyObject.

(Inherited from DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback.

(Inherited from DependencyObject)

Applies to

See also