Reputation: 6145
I have the following class schema
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
}
Essentially I have a collection of Test objects, and I want to bind the Thickness value for each one to its corresponding UI element. I am not too familiar with C# binding. When I try to create multiple objects, I am running into "DependencyProperty is already registered" issue. I am sure that I am just missing some key concept for binding to DependencyProperty.
Any help is appreciated!
Upvotes: 0
Views: 191
Reputation: 50712
You are registering the Thickness DependencyProperty on the CounterDataStreamWrapper type and private per instance.
Make the DependencyProperty public static and register it for the class Test.
public static DependencyProperty Thickness =
DependencyProperty.Register("Thickness", typeof(double), typeof(Test));
Upvotes: 4
Reputation: 26338
It's supposed to be static. Like this:
private static DependencyProperty _thickness ...
Upvotes: 3