One of the obvious differences between HTML and WPF layout design is WPF using Margin as the main way to coordinates the object. Since WPF support vector graphic, margin is the encouraging way to do the layout arrangement. It really take some times for traditional developers to switch the mindset. For WPF, you don’t really need to specific the width and height to give the size of the object. However it depends on the Margin that you set and do the resizing accordingly.
Well let’s take a look at some of the common issues facing by most developers when using Margin.
When developers reading at the Intellisense definition of the function (as stated below if you cannot read from the screenshots)
Public Property Left() as Double
Gets or sets the width, in pixels, of the left side of the bounding rectangle.
Naturally, I enter a double data type to the property like below
Me.Button1.Margin.Left = 200.0
Immediately the Visual Studio showing me the error message as below
Expression is a value and therefore cannot be the target of an assignment
According to definition, Left() support both Read and Write operation and the data type must be double. It is definitely misleading me as a developer. After reading some article, below are the solution.