Decorator Content Model Overview

This content model overview describes the supported content for a Decorator. The Border control is a type of Decorator.

This topic contains the following sections.

  • Decorator Content Property
  • Using the Child Property
  • Types That Share This Content Model
  • Types That Can Contain Decorator Objects
  • Related Topics

Decorator Content Property

A Decorator has the following content properties.

The following illustration shows a TextBox decorated with a Border around it.

TextBox with black border

Using the Child Property

The Child property specifies the single UIElement that the Decorator effects (decorates). The following example shows how to use the Child property to add a TextBox to a Border.

<Page xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml">
    <Border BorderThickness="20" BorderBrush="Black">
      <TextBox>TextBox with a black Border around it</TextBox>
    </Border>
</Page>
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace SDKSample
{
    public partial class BasicBorderExample : Page
    {
        public BasicBorderExample()
        {

            TextBox myTextBox = new TextBox();

            // Put some initial text in the TextBox.
            myTextBox.Text = "TextBox with a black Border around it";

            // Create a Border
            Border myBorder = new Border();
            myBorder.BorderThickness = new Thickness(20);
            myBorder.BorderBrush = Brushes.Black;

            // Add TextBox to the Border.
            myBorder.Child = myTextBox;
            // myStackPanel.Children.Add(myTextBox);
            this.Content = myBorder; 
        }
    }
}

Types That Share This Content Model

The following classes inherit from the Decorator class.

Types That Can Contain Decorator Objects

You can use the ItemsControl class as content for the following types:

See Also

Reference

Decorator

Concepts

Decorator Types

Other Resources

Content Models
Type Families