diff --git a/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.wasm.cs b/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.wasm.cs index ee0a4a04e0ee..c397e6189bce 100644 --- a/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.wasm.cs +++ b/src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.wasm.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; using Uno.Disposables; using Uno.Extensions; @@ -18,6 +19,7 @@ internal class BorderLayerRenderer public void UpdateLayer( UIElement element, Brush background, + BackgroundSizing backgroundSizing, Thickness borderThickness, Brush borderBrush, CornerRadius cornerRadius, diff --git a/src/Uno.UI/UI/Xaml/FrameworkElement.cs b/src/Uno.UI/UI/Xaml/FrameworkElement.cs index cfba5e7ee54f..00c0cae8d8d6 100644 --- a/src/Uno.UI/UI/Xaml/FrameworkElement.cs +++ b/src/Uno.UI/UI/Xaml/FrameworkElement.cs @@ -121,7 +121,11 @@ internal BackgroundSizing BackgroundSizing private protected virtual void OnBackgroundSizingChanged(DependencyPropertyChangedEventArgs e) { + OnBackgroundSizingChangedPartial(e); } + + partial void OnBackgroundSizingChangedPartial(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs); + #endregion diff --git a/src/Uno.UI/UI/Xaml/FrameworkElement.wasm.cs b/src/Uno.UI/UI/Xaml/FrameworkElement.wasm.cs index 74a35784a457..167a2650e4ed 100644 --- a/src/Uno.UI/UI/Xaml/FrameworkElement.wasm.cs +++ b/src/Uno.UI/UI/Xaml/FrameworkElement.wasm.cs @@ -204,6 +204,14 @@ protected void SetCornerRadius(CornerRadius cornerRadius) protected void SetBorder(Thickness thickness, Brush brush) => BorderLayerRenderer.SetBorder(this, thickness, brush); + partial void OnBackgroundSizingChangedPartial(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) + { + if (dependencyPropertyChangedEventArgs.NewValue is BackgroundSizing sizing) + { + SetStyle("background-clip", sizing == BackgroundSizing.InnerBorderEdge ? "padding-box" : "border-box"); + } + } + internal override bool IsEnabledOverride() => IsEnabled && base.IsEnabledOverride(); #region Margin Dependency Property diff --git a/src/Uno.UI/WasmCSS/Uno.UI.css b/src/Uno.UI/WasmCSS/Uno.UI.css index 4fb1204c0d79..12143158116d 100644 --- a/src/Uno.UI/WasmCSS/Uno.UI.css +++ b/src/Uno.UI/WasmCSS/Uno.UI.css @@ -40,6 +40,11 @@ body { See WindowManager.ts on measureViewInternal() for more details. */ transform: translate(0, 0); + + /* + By default, the background of UWP controls is not drawn under the border of the control. + */ + background-clip: padding-box; } .uno-uielement .noclip {