Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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.

A Decorator has the following content properties.

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

TextBox with black border

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

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://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; 
        }
    }
}

Community Additions

Show:
© 2014 Microsoft