Decorator 內容模型概觀
更新:2007 年 11 月
本內容模型概觀說明 Decorator 支援的內容。Border 控制項是一種 Decorator。
這個主題包含下列章節。
- Decorator 內容屬性
- 使用 Child 屬性
- 共用此內容模型的型別
- 可以包含 Decorator 物件的型別
- 相關主題
Decorator 內容屬性
Decorator 具有下列內容屬性。
使用 Child 屬性
Child 屬性會指定 Decorator 所影響 (裝飾) 的單一 UIElement。下列範例顯示如何使用 Child 屬性將 TextBox 加入至 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;
}
}
}
共用此內容模型的型別
下列類別繼承自 Decorator 類別。
可以包含 Decorator 物件的型別
請參閱 WPF 內容模型。