diff --git a/Perspex.Direct2D1.RenderTests/Controls/BorderTests.cs b/Perspex.Direct2D1.RenderTests/Controls/BorderTests.cs index 4dbf79fd74..f657e5eb2c 100644 --- a/Perspex.Direct2D1.RenderTests/Controls/BorderTests.cs +++ b/Perspex.Direct2D1.RenderTests/Controls/BorderTests.cs @@ -73,5 +73,28 @@ namespace Perspex.Direct2D1.RenderTests.Controls this.RenderToFile(target); this.CompareImages(); } + + [TestMethod] + public void Border_Brush_Offsets_Content() + { + Decorator target = new Decorator + { + Padding = new Thickness(8), + Width = 200, + Height = 200, + Content = new Border + { + BorderBrush = Brushes.Black, + BorderThickness = 2, + Content = new Border + { + Background = Brushes.Red, + } + } + }; + + this.RenderToFile(target); + this.CompareImages(); + } } } diff --git a/Perspex/Controls/Border.cs b/Perspex/Controls/Border.cs index 8d6c3415f0..eca7ad776d 100644 --- a/Perspex/Controls/Border.cs +++ b/Perspex/Controls/Border.cs @@ -40,5 +40,23 @@ namespace Perspex.Controls } } } + + protected override Size ArrangeContent(Size finalSize) + { + Control content = this.Content; + + if (content != null) + { + Thickness padding = this.Padding + new Thickness(this.BorderThickness); + content.Arrange(new Rect(finalSize).Deflate(padding)); + } + + return finalSize; + } + + protected override Size MeasureContent(Size availableSize) + { + return this.DefaultMeasure(availableSize, this.Padding + new Thickness(this.BorderThickness)); + } } } diff --git a/Perspex/Controls/Decorator.cs b/Perspex/Controls/Decorator.cs index 36e74ea079..8d6d0adfaa 100644 --- a/Perspex/Controls/Decorator.cs +++ b/Perspex/Controls/Decorator.cs @@ -76,6 +76,11 @@ namespace Perspex.Controls } protected override Size MeasureContent(Size availableSize) + { + return this.DefaultMeasure(availableSize, this.Padding); + } + + protected Size DefaultMeasure(Size availableSize, Thickness padding) { double width = 0; double height = 0; diff --git a/TestFiles/Direct2D1/Controls/Border/Border_Brush_Offsets_Content.expected.png b/TestFiles/Direct2D1/Controls/Border/Border_Brush_Offsets_Content.expected.png new file mode 100644 index 0000000000..d1c13a9e57 Binary files /dev/null and b/TestFiles/Direct2D1/Controls/Border/Border_Brush_Offsets_Content.expected.png differ