WPF has Decorator class which can contain a single child element.
Windows Runtime has no Decorator class but has similar Border class which also can contain child element. Unfortunately Border class is sealed.
I can derive from Control and write a ControlTemplate with ContentPresenter for my child.
How the Border class is written? Here's my example which is not working.
[ContentProperty(Name = "Child")]
public class TextBlockDecorator : FrameworkElement
{
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(
"Child", typeof(TextBlock), typeof(TextBlockDecorator), new PropertyMetadata(null));
public TextBlock Child
{
get { return (TextBlock)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}
}
When I use it Child TextBlock is not shown. How can I add it as a Child to my Decorator element? I think, I'm missing some call like AddVisualChild... or similar