0

次のクラススキーマがあります

public Class Test : DependencyObject 
{
    private DependencyProperty _thickness = DependencyProperty.Register("Thickness", typeof(double), typeof(CounterDataStreamWrapper));
    public double Thickness
    {
        get 
        { 
            return (double)GetValue(this._thickness); 
        }
        set
        {
            SetValue(this._thickness, value);
        }
    }


    ... Rest of the code
}

基本的に、Test オブジェクトのコレクションがあり、それぞれの Thickness 値を対応する UI 要素にバインドしたいと考えています。私は C# バインディングにあまり詳しくありません。複数のオブジェクトを作成しようとすると、「DependencyProperty は既に登録されています」という問題が発生します。DependencyProperty にバインドするためのいくつかの重要な概念が欠落していると確信しています。

どんな助けでも大歓迎です!

4

2 に答える 2

4

CounterDataStreamWrapper タイプとインスタンスごとのプライベートに Thickness DependencyProperty を登録しています。

DependencyProperty public static を作成し、クラス Test に登録します。

public static DependencyProperty Thickness = 
    DependencyProperty.Register("Thickness", typeof(double), typeof(Test));
于 2012-08-03T19:16:56.673 に答える
3

静的であるはずです。このような:

private static DependencyProperty _thickness ...
于 2012-08-03T19:14:39.823 に答える