次の方法で共有


Decorator コンテンツ モデルの概要

更新 : 2007 年 11 月

このコンテンツ モデルの概要では、Decorator でサポートされるコンテンツについて説明します。Border コントロールは、Decorator の一種です。

このトピックには次のセクションが含まれています。

  • Decorator コンテンツ プロパティ
  • 子プロパティの使用
  • このコンテンツ モデルを共有する型
  • Decorator オブジェクトを含むことのできる型
  • 関連トピック

Decorator コンテンツ プロパティ

Decorator には次のコンテンツ プロパティがあります。

周囲を Border で装飾した TextBox を次の図に示します。

境界線が黒の TextBox

子プロパティの使用

Child プロパティは、Decorator の効果の対象となる (装飾する) 単一の UIElement を指定します。Child プロパティを使用して TextBoxBorder に追加する方法の例を次に示します。

<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; 
        }
    }
}

このコンテンツ モデルを共有する型

次のクラスは、Decorator クラスから継承されます。

Decorator オブジェクトを含むことのできる型

WPF のコンテンツ モデル」を参照してください。

参照

参照

Decorator