2011-12-14 9 views
0

これは非常に速い(おそらくnoobの)質問です。 私はdependencyobjectを作成していますが、私のdependencypropertyの1つは "Point"になります。C#Type "Point"のOwnerClass?

の事は私が作成していたDependencyPropertyの「ownerclass」であるのか分からないということです:/ をここでは、コードは次のとおりです。

public Point MyPoint 
    { 
     get { return (Point)GetValue(MyPointProperty); } 
     set { SetValue(MyPointProperty, value); } 
    } 

    public static readonly DependencyProperty MyPointProperty = 
     DependencyProperty.Register("MyPoint", typeof(Point), typeof(**???**), new UIPropertyMetadata(0)); 

そして、ところで、メタデータはOKですか? ( "Point"のパラメータとして整数を取るコンストラクタがあります)

答えて

3

Registerのドキュメント内には1つの例しかありませんが、十分に分かりやすいでしょう - このプロパティを追加するクラスですあなたがメタデータにわからない場合は、Registerのオーバーロードがあります

public class MySpecialClass { 
    public Point MyPoint 
    { 
     get { return (Point)GetValue(MyPointProperty); } 
     set { SetValue(MyPointProperty, value); } 
    } 

    public static readonly DependencyProperty MyPointProperty = 
     DependencyProperty.Register("MyPoint", typeof(Point), typeof(MySpecialClass), new UIPropertyMetadata(0)); 
} 

「tは、残念ながら、私達にあなたのクラス宣言を示したので、私はあなたが必要実際値を投稿することはできません)が、のようなもの3つのパラメータしかないので、メタデータを指定する必要はありません。

+0

本当に疲れています...ごめんなさい:( –

関連する問題