Placing elements in exact positions
WPF's layout panels provide much flexibility in building a user interface. Furthermore, most of the panels adapt well to size and content changes of themselves and their child elements. This means that positions and sizes don't necessarily remain the same as the user resizes or otherwise manipulates the UI.
Most of the time that's a good thing; sometimes, however, we need to place elements in exact positions without them moving unexpectedly. This is typical of highly graphical content, such as graphs, charts, or animations. The
Canvas panel provides a convenient container for such content.
Make sure Visual Studio is up and running.
How to do it...
We'll create a simple application that hosts a