Only this week 80 % discount on e-learning courses of C# .NET
Get up to 60 % extra points for free! More info
discount  week 60

Lesson 39 - WPF - Container Controls

In the previous lesson, WPF - Menu and Dialog Controls, we continued with our overview of WPF controls and showed how to use application menus and dialogs. Today's and the last tutorial on the basic WPF controls is dedicated to containers.


Containers are controls that contain other controls. We already know at least the Grid and StackPanel. We use them to align controls in the form according to the rules of the used container type.

Representatives of these containers in WPF are:

  • Canvas
  • DockPanel
  • Grid
  • StackPanel
  • TabControl
  • WrapPanel


Canvas is the simplest container. Elements are placed in it using the Left, Top, Right, and Bottom properties, as shown in the following example. The element position is then specified by the distance from these edges. The underlying elements are stacked in the order in which they are defined. We use Canvas mainly for drawing, e.g. some diagrams using geometric shapes or pictures.

Canvas in C# .NET WPF



<Canvas Background="LightSteelBlue">
    <Button Canvas.Left="10" Canvas.Top="10" Content="Top left"/>
    <Button Canvas.Right="10" Canvas.Top="10" Content="Top right"/>
    <Button Canvas.Left="10" Canvas.Bottom="10" Content="Bottom left"/>
    <Button Canvas.Right="10" Canvas.Bottom="10" Content="Bottom right"/>

    <Rectangle Fill="Lime" Canvas.Left="130"
       Canvas.Top="70" Width="50" Height="50"


...End of the preview...
Continue further

You will gain knowledge worth hundreds of thousands for a few crowns

You've come here and that's great! We believe that the first lessons showed you something new and useful
Do you want to continue the course? Go to the premium section.

Limited offer: Learn all knowledge and save money

Buy lessons and exercise submitting one by one 250 points
Buy all currently available lessons with exercise submitting and other features for an exclusive price 198 points ($17.82)
Currently, you have 0 points
By buying this exclusive package, you'll have access to all 44 lessons in this course including exercise submitting while saving $4.68. This is a time limited offer for all lessons in this course. Buy it now and gain a limited 21% discount.
You gain 198 points for adding an article to the site, or for $22.50 $17.82
Buy only the lesson 10 points
Currently, you have 0 points
You gain 10 points for adding an article to the site, or for $0.90

This article is licensed: Premium, by buying this article, you agree with the terms of use.

What will you get from us in the next lessons?
  • Unlimited and permanent access to individual lessons.
  • High quality IT knowledge.
  • Skills to help you get your dream and well-paid job.

Article description

Requested article covers this content:

In this C# .NET WPF tutorial, we'll complete our control overview with containers. These are Canvas, DockPanel, Grid, StackPanel, TabControl, and WrapPanel

You gain points by supporting our network. This is done by sending a helpful amount of money to support the site, or by creating content for the network.

Article has been written for you by Petr Pospisil