I have an object(class): Foo
.
It has a property: Bar
.
What should I do to be able to Bind to that 'Bar
' property?
(WPF, .NET 4)
EDIT:
TO be more explicit, I give an example:
I have a Dot:UserControl
I create 2 properties of Dot - CenterX and CenterY:
public double CenterX
{
get
{
return Canvas.GetLeft(this) + this.Width / 2;
}
set
{
Canvas.SetLeft(this, value - this.Width / 2);
}
}
public double CenterY
{
get
{
return Canvas.GetTop(this) + this.Height / 2;
}
set
{
Canvas.SetLeft(this, value - this.Height / 2);
}
}
Now:
<Line Stroke="Black" x:Name="line1"
X1="{Binding ElementName=dot1, Path=CenterX}"
Y1="{Binding ElementName=dot1, Path=CenterY}"
X2="{Binding ElementName=dot2, Path=CenterX}"
Y2="{Binding ElementName=dot2, Path=CenterY}" />
does not work...