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 horizontally

Apart from arranging controls vertically, it is possible to place them in a linear horizontal way, where a control is placed on the right-hand side of the previous one. This task can be accomplished using StackPanel as well, as shown in this recipe.

Getting ready

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

How to do it...

To arrange controls horizontally, modify the content of the MainPage.xaml file, as shown in the following code:

        <Page (...)> 
            <StackPanel 
                Orientation="Horizontal" Background="White" Padding="20"> <TextBlock Text="Grade:" VerticalAlignment="Center" /> <Button Content="1" Margin="20 0 10 0" /> <Button Content="2" Margin="10 0" /> <Button Content="3" Margin="10 0" /> ...

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