Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3670204
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:20:09+00:00 2026-05-19T02:20:09+00:00

Im new in WPF & Xaml I dont know how to anchor how to

  • 0

Im new in WPF & Xaml
I dont know how to anchor how to dock…
On this screen gray is statusBar is docked but grid and menu is not all components are in canvas.
This is XAML

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication6.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">

<Grid x:Name="LayoutRoot">
    <Canvas>
        <StackPanel Height="40" Width="624" VerticalAlignment="Top" HorizontalAlignment="Center">
            <Menu Height="39" Margin="1,0,0,0">
                <Menu.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#FFF6F6F6" Offset="0.25"/>
                        <GradientStop Color="#FFEAE8E8" Offset="0.25"/>
                        <GradientStop Color="#FFDCD9D9" Offset="0.8"/>
                        <GradientStop Color="White" Offset="1"/>
                    </LinearGradientBrush>
                </Menu.Background>
            </Menu>
        </StackPanel>
        <StackPanel Height="356" Canvas.Top="44" Width="161" HorizontalAlignment="Left">
            <Expander Header="Expander" Height="107">
                <Grid Background="#FFE5E5E5"/>
            </Expander>
        </StackPanel>
        <StackPanel Height="360" Canvas.Left="161" Canvas.Top="40" Width="463">
            <DataGrid Height="361"/>
        </StackPanel>
    </Canvas>
    <StackPanel Height="40" Margin="-1,0,0,0" VerticalAlignment="Bottom">
        <StatusBar Height="40" Background="#FF897676"/>
    </StackPanel>
</Grid>

alt text

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T02:20:10+00:00Added an answer on May 19, 2026 at 2:20 am

    You don’t want these things to go in a Canvas. I’m not sure I’ve ever used a Canvas in WPF.

    DockPanel is your friend, and this is how it works:

    • Each control in the DockPanel gets a DockPanel.Dock attached property : Left, Top, Right, or Bottom
    • What, no Fill? This is important: You can have one control fill up available space, and that will be the last control declared in the DockPanel. So, even if you want the “fill” control to be at the very top, you make it the last item in the DockPanel and set DockPanel.Dock="Top".
    • Other than the last, “fill” item, others which have the same dock setting will be docked in the order in which they were declared.

    At its most basic, DockPanel can be used just like StackPanel except it will fill available space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to WPF/XAML & I'm just doing a training exercise at the moment.
being new to WPF this is a complex problem for me. What i want
I'm working on a Metro app using XAML & C#. I started this using
I am trying to implement MVVM in a new project (based on WPF &
I like the new Colorpicker in Extended WPF Toolkit, but it is for .NET
I put this WPF application http://tanguay.info/web/index.php?pg=codeExamples&id=164 together http://tanguay.info/web/index.php?pg=codeExamples&id=164 which reads an XML file of
This seems really easy, but it's definitely not working as expected. In WPF 4.0,
I'm trying to implement a WPF application with drag&drop functionality using MouseDragElementBehavior. But I
I'm very much new in WPF & MVVM paradigm and i'm trying hard to
I'm fairly new to C# and WPF programing and right now this problem is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.