I needed to move a XPF/XAML control programmatically and didn’t really need it animated so did the same thing i always did in Windows forms:
-Which of course gave me the error:
Error 1 ‘Left’ is not a member of ‘System.Windows.Controls.Button’. C:\Users\chass\Documents\Usercontroltest\Usercontroltest\Page1.xaml.vb 8 9 Usercontroltest
Looking at the designer i see we are now setting left in the margin property! So i try the following:
Button1.Margin.Left = 10
Which nets me the error:
Error 1 Expression is a value and therefore cannot be the target of an assignment. C:\Users\chass\Documents\Usercontroltest\Usercontroltest\Page1.xaml.vb 8 9 Usercontroltest
Looking up the Margin property i see it is of type Thickness. So trying the following code nets me movement to the left!
Dim movleft As New Thickness
movleft.Left = -10
Button1.Margin = movleft
But interestingly this code doesn’t move my control off the canvas but rather increases the distance to the left. – Which of course I see is documented -after the fact.