J'ai un objet (classe): Foo
.Lier à un objet
Il a la propriété: Bar
.
Que dois-je faire pour pouvoir lier cette propriété 'Bar
'?
(WPF, .NET 4)
EDIT:
être plus explicite, je donne un exemple:
J'ai un Dot:UserControl
je créer 2 propriétés Dot - CenterX et 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);
}
}
maintenant:
<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}" />
ne fonctionne pas ...
WPF? Winforms? Autre? –
.NET 4 WPF ou ASP.NET ou WinForms? D'où venez-vous? Est-ce que 'Foo' est une instance, ou la classe, et comment l'endroit à partir duquel vous liez peut-il être' Foo'? –
Désolé, j'ai oublié, c'est pour WPF – serhio