Tuesday, May 13, 2008 12:35 AM
I've tried the following but it is not working:
Bindingbinding = new Binding();
binding.Source = element;
binding.Path =new PropertyPath("Canvas.TopProperty");
How can I get it to work?
Wednesday, May 14, 2008 2:56 AMTo get this working, the UIElement identified by "element" variable should be added into Canvas.Children collection.
hope this helps
Wednesday, May 14, 2008 6:42 AM
As Marco said your line should belong to desired canvas children collection. Also you can use direct dependency property instead of string representation. Something like
Bindingbinging = new Binding();
binging.Path =new PropertyPath(Canvas.TopProperty);
Thursday, May 15, 2008 5:20 AM
That original code is OK too, you just need to change the PropertyPath from
... The first difference is to specify the property as "Top", rather than "TopProperty", because this syntax is specifying the CLR property, not the backing DP. The second difference is to use parens, indicating that this is an attached property.