クリックして評価とフィードバックをお寄せください
MSDN
MSDN ライブラリ
.NET 開発
.NET Framework 3.5
.NET Framework 3.5
System.Windows.Markup 名前空間
ContentPropertyAttribute クラス

  低帯域幅での表示をオンにする
このページは次のバージョンについて記述しています。
Microsoft Visual Studio 2008/.NET Framework 3.5

その他のバージョンについては、以下の情報を参照してください。
.NET Framework クラス ライブラリ
ContentPropertyAttribute クラス

更新 : 2007 年 11 月

XAML として書き込む場合に、クラスのどのプロパティをコンテンツ プロパティとして使用するかを指定します。

名前空間 :  System.Windows.Markup
アセンブリ :  WindowsBase (WindowsBase.dll 内)
XAML の XMLNS : xmlns にマップされていません。

Visual Basic (宣言)
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False, Inherited := True)> _
Public NotInheritable Class ContentPropertyAttribute _
    Inherits Attribute
Visual Basic (使用法)
Dim instance As ContentPropertyAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public sealed class ContentPropertyAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false, Inherited = true)]
public ref class ContentPropertyAttribute sealed : public Attribute
J#
/** @attribute AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false, Inherited = true) */
public final class ContentPropertyAttribute extends Attribute
JScript
public final class ContentPropertyAttribute extends Attribute
XAML
<p>通常、このマネージ クラスは XAML では使用しません。</p>

ContentPropertyAttribute の関連付けられているプロパティが、型文字列またはオブジェクト以外の場合、コンバータが実行時に呼び出されます。型コンバータが実行時に見つからなかった場合は、例外がスローされます。

複数のオブジェクト要素をコンテンツとして受け入れるためには、コンテンツ プロパティの型はコレクション型であることが必要です。

ContentPropertyAttribute を使用する Windows Presentation Foundation (WPF) にあるクラスの例には ContentControl があります。Button クラスは、このクラスを継承します。ContentControl 上のプロパティ Content は、ContentPropertyAttribute によって設定されるコンテンツ プロパティです。Button が XAML でインスタンス化される場合、ButtonContent は開始ボタン タグと終了ボタン タグの間にある要素に設定されます。

次の例では、ContentPropertyAttribute で修飾する Film という名前のクラスを作成します。Title という名前のプロパティは、コンテンツ プロパティとして設定されます。

C#
[ContentProperty("Title")]
public class Film
{
    public Film()
    {
    }

    public string Title
    {
        get { return _title; }
        set { _title = value; }
    }

    private string _title;
}

System..::.Object
  System..::.Attribute
    System.Windows.Markup..::.ContentPropertyAttribute
この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

Windows Vista

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

.NET Framework

サポート対象 : 3.5、3.0
コミュニティ コンテンツ   コミュニティ コンテンツとは
新しいコンテンツの追加 RSS  注釈
Processing
© 2009 Microsoft Corporation. All rights reserved. 使用条件  |  商標  |  プライバシー
Page view tracker