Windows 10 17763 SDK added an interesting property called
BackgroundSizing to all controls with a
Background. Let’s see what it can do.
BackgroundSizing is useful for controls with a transparent or semi-transparent
Border as it can control whether or not the background of the control extends underneath the border. Suppose we have the following XAML:
By not specifying the
BackgroundSizing attribute, the default value is used –
InnerBorderEdge. This means the background does not extend beyond the inner edge of the border:
Now let’s change the
In this case, the background
ImageBrush will extend below the border and thanks to the fact that
BorderBrush is set to be semi-transparent, it will blend with the background and create a nice effect:
BackgroundSizing property is available when targeting Windows 10 build 17763 and newer, but as soon as WinUI 3.0 is released, it will be available for all supported versions of Windows 10!
A sample project for this article is available on my GitHub.