O'Reilly logo

Windows Application Development Cookbook by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Arranging controls in absolute positions

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.

Getting ready

To step through this recipe, you only need the automatically generated project.

How to do it...

To create a page presenting how to arrange controls in absolute positions, perform the following steps:

  1. Add the Image.jpg file to the Assets directory.
  2. Modify the content of the MainPage.xaml file as follows:
            <Page (...) Background="Black"> 
                <Canvas> 
                    <Canvas.Background> <ImageBrush ImageSource="/Assets/Image.jpg" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required