C# XAML Layouts


There are several layout controls to choose from when designing your Windows application. For example, if you are designing an About window you may wish to use the Grid control. You could define several rows. The top row will be reserved for a logo and program name information and may use a Canvas control. The row will have a fixed height. The next row could give a one-line description of copyright information. It will contain a Canvas control with a Label control. It will also be a fixed height. The third row could have a few Label controls and Text Blocks and will not have a fixed height. The last row could have a fixed height and only display a Close button.

Several examples of layouts can be written in a Visual Studio Solution that contains one Project.

SolutionLayoutExamples
Each example runs in its own window. In order to run each of the windows you need to change the StarupUri in the App.xaml file. The App.xaml file is shown below.

<Application x:Class="LayoutExamples.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:LayoutExamples"
             StartupUri="WrapPanel.xaml">
    <!-- Edit the StartupUri in App.xaml to see each of the examples 
         Canvas.xaml
         DockPanels.xaml
         StackPanels.xaml
         WrapPanel.xaml
    -->
    <Application.Resources>
         
    </Application.Resources>
</Application>

Leave a comment

Your email address will not be published. Required fields are marked *