In some scenarios, it may be necessary to place controls in absolute positions in a given area. Such a task can be performed using the Canvas
control. In this recipe, you will learn how to place a rectangle and an ellipse over the image in a fixed location, specified in pixels from the top-left corner.
To create a page presenting how to arrange controls in absolute positions, perform the following steps:
Add the
Image.jpg
file to theAssets
directory.Modify the content of the
MainPage.xaml
file as follows:<Page (...) Background="Black"> <Canvas> <Canvas.Background> <ImageBrush ImageSource="/Assets/Image.jpg" Stretch="UniformToFill" /> </Canvas.Background> ...