diff --git a/src/Perspex.Controls/Panel.cs b/src/Perspex.Controls/Panel.cs index b3a95ca72c..0da3d2800e 100644 --- a/src/Perspex.Controls/Panel.cs +++ b/src/Perspex.Controls/Panel.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using Perspex.Collections; +using Perspex.Media; namespace Perspex.Controls { @@ -18,6 +19,12 @@ namespace Perspex.Controls /// public class Panel : Control, IReparentingControl, IPanel { + /// + /// Defines the property. + /// + public static readonly PerspexProperty BackgroundProperty = + Border.BackgroundProperty.AddOwner(); + private readonly Controls _children = new Controls(); private ILogical _childLogicalParent; @@ -57,6 +64,15 @@ namespace Perspex.Controls } } + /// + /// Gets or Sets Panel background brush. + /// + public Brush Background + { + get { return GetValue(BackgroundProperty); } + set { SetValue(BackgroundProperty, value); } + } + /// /// Requests that the visual children of the panel use another control as their logical /// parent. @@ -146,5 +162,21 @@ namespace Perspex.Controls InvalidateMeasure(); } + + /// + /// Renders the visual to a . + /// + /// The drawing context. + public override void Render(IDrawingContext context) + { + Brush background = Background; + if (background != null) + { + var renderSize = Bounds.Size; + context.FillRectange(background, new Rect(renderSize)); + } + + base.Render(context); + } } }