Click here to Skip to main content
15,894,825 members
Articles / Desktop Programming / WPF

Creating a WPF DockPanel using XAML

Rate me:
Please Sign up or sign in to vote.
4.17/5 (6 votes)
17 Mar 2010CPOL1 min read 43K   1.4K   15  
Beginners tutorial on how to create a DockPanel using XAML
<Window x:Class="WpfDockPanelExample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Sundeepan's DockPanel Example">
    
    <DockPanel LastChildFill="True">
        <TextBlock DockPanel.Dock="Top" 
                   Background="OliveDrab"
                   Foreground="Cornsilk"
                   FontFamily="Veranda"
                   FontSize="20"
                   TextAlignment="Center">
            w00h00, look at me, im on top of the world!!!!</TextBlock>
        <TextBlock DockPanel.Dock="Bottom" 
                   Background="Cornsilk"
                   Foreground="OliveDrab"
                   FontFamily="Veranda"
                   FontSize="20"
                   TextAlignment="Center">
            aww shucks, I am on the bottom now..in the pits!!!!</TextBlock>
        <TextBlock DockPanel.Dock="Left" 
                   VerticalAlignment="Center"
                   Background="Bisque"
                   Foreground="DarkGoldenrod"
                   FontFamily="Veranda"
                   FontSize="20">
            I am the left!</TextBlock>
        <TextBlock DockPanel.Dock="Right" 
                   VerticalAlignment="Center"
                   Background="DarkGoldenrod"
                   Foreground="Bisque"
                   FontFamily="Veranda"
                   FontSize="20"
                   TextAlignment="Center">
            I am the right!</TextBlock>
        <Button Height="40" Width="200" Click="Button_Click">
            I am the fill!("Pour down center!")
        </Button>            

    </DockPanel>               

</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems Engineer
United States United States
Sundeepan Sen has been involved with technology for as long as he can remember. He got his start with the internet as a sophomore in high school in 1995 at the age of 15 and hasn't stopped since. His first encounter with the Internet was on a 2400 baud modem on a VAX/VMS shell account. The first program he wrote is in assembly for a game called "Core War" it can be found here:

http://para.inria.fr/~doligez/corewar/post/JUMP.txt

He likes all things technology and loves to learn anything that comes his way.

Sundeepan is also artistically gifted with music, graphics, drawing and poetry.

He is a Network Consultant providing services with the latest Microsoft technologies.

Comments and Discussions