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 3876832
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:25:40+00:00 2026-05-19T22:25:40+00:00

In my WPF application (XAML posted below), I have a List View and below

  • 0

In my WPF application (XAML posted below), I have a List View and below that I have some labels and text boxes. Everything below the ListView should anchor to the bottom of the window. Everything above the ListView needs to anchor to the top of the window. The ListView itself needs to expand vertically to fill in the space between. When I resize my window vertically, the only thing that should be changing size is the list view.

I keep everything in a stack panel at the root, but it doesn’t size the listview like I want. Anyone know how I can accomplish this? I’m using C# .NET 4.0 and VS2010.

<Window x:Class="TaskManager.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" MinWidth="525" MinHeight="400">
    <StackPanel Orientation="Vertical">
        <Menu Name="mainMenu" Margin="0,0,0,5">
            <MenuItem Header="File">
                <MenuItem Header="Quit" />
            </MenuItem>
        </Menu>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,0,5">
            <Label>View tasks for user:</Label>
            <ComboBox Name="userList" MinWidth="150"></ComboBox>
        </StackPanel>
        <ListView Name="taskView" VerticalContentAlignment="Stretch">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Task" Width="300"/>
                    <GridViewColumn Header="Hours" Width="50"/>
                </GridView>
            </ListView.View>
        </ListView>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="353*" />
                <ColumnDefinition Width="97*" />
                <ColumnDefinition Width="53" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Grid.Column="0">Task Description</Label>
            <TextBox Grid.Row="1" Grid.Column="0"/>
            <Label Grid.Row="0" Grid.Column="1">Hours</Label>
            <TextBox Grid.Row="1" Grid.Column="1"/>
            <Button Grid.Row="1" Grid.Column="2">Add</Button>
        </Grid>
    </StackPanel>
</Window>
  • 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-19T22:25:40+00:00Added an answer on May 19, 2026 at 10:25 pm

    It sounds like the DockPanel would help you to get the desired result. In the DockPanel, you can dock parts of your view to the top, bottom, left or right of the window. The last element added always covers the rest of the window. I modified your StackPanel code below.

    <DockPanel>
        <Menu DockPanel.Dock="Top" Name="mainMenu" Margin="0,0,0,5">
            <MenuItem Header="File">
                <MenuItem Header="Quit" />
            </MenuItem>
        </Menu>
        <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,0,5">
            <Label>View tasks for user:</Label>
            <ComboBox Name="userList" MinWidth="150"></ComboBox>
        </StackPanel>
        <Grid DockPanel.Dock="Bottom">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="353*" />
                <ColumnDefinition Width="97*" />
                <ColumnDefinition Width="53" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Grid.Column="0">Task Description</Label>
            <TextBox Grid.Row="1" Grid.Column="0"/>
            <Label Grid.Row="0" Grid.Column="1">Hours</Label>
            <TextBox Grid.Row="1" Grid.Column="1"/>
            <Button Grid.Row="1" Grid.Column="2">Add</Button>
        </Grid>
        <ListView Name="taskView" VerticalContentAlignment="Stretch">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Task" Width="300"/>
                    <GridViewColumn Header="Hours" Width="50"/>
                </GridView>
            </ListView.View>
        </ListView>
    </DockPanel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF application in VS 2008 with some web service references. For
I have written a WPF application that I want to port to Silverlight 2.
I'm making a WPF application that is comprised of Screens (Presenter + View). I
I have a WPF application that runs fine under XP as an administrator. When
We have a WPF application that is loading a usercontrol at runtime from the
I have a WPF application that I need to have users access directories in.
I want my WPF application to be skinnable, by applying a certain XAML template,
I have a simple WPF application which I am trying to start. I am
I have a simple WPF application with a menu. I need to add menu
I have a usercontrol in my wpf application which is causing a stackoverflowexception to

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.