How to set MyControl.X and MyControl.Y in a Windows Presentation Foundation (WPF) Canvas?


WPF elements (like Button and Rectangle) do not have the X and Y properties as in the WinForms controls. Using procedural code, to place a WPF element  at a specific XY on a free-form work area like a Canvas, you can use Canvas.SetLeft() and Canvas.SetTop(). Using XAML, you can use the attribute Canvas.Left and Canvas.Top.


Also try using Intellisense on Canvas.Set* to see other available properties that can be changed this way.


For advanced reading, see WPF Dependency Properties. http://msdn2.microsoft.com/en-us/library/ms752914.aspx


-Tan