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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:13:26+00:00 2026-06-07T23:13:26+00:00

I have a control which is a grid where the first row contains some

  • 0

I have a control which is a grid where the first row contains some buttons, with fixed height, and the second (and last) row contains a ListView. Then I have a main screen which contains only a menu and this user control above. I would like to have the size of the ListView as the maximum for the window, which means that if the window is maximized the ListView will be large, in case the window is smaller, so is the ListView (with vertical scroll to help navigating through items).

This is how I am doing it:
Window:

<Window x:Class="TestUI.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Width="auto" Height="auto"
    MinHeight="300" MinWidth="300"
    Title="Test"
    DataContext="{Binding MainViewModel, Source={StaticResource Locator}}" >

<StackPanel Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
    <DockPanel>
        <Menu DockPanel.Dock="Top" >
            <MenuItem Header="Item 1" Command="{Binding Command1}"/>
            <MenuItem Header="Item 2" Command="{Binding Command2}"/>
            <MenuItem Header="Item 3" Command="{Binding Command3}"/>
        </Menu>
    </DockPanel>
    <DockPanel LastChildFill="True">
        <ScrollViewer Content="{Binding Content}" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled" DockPanel.Dock="Bottom" />
    </DockPanel>
</StackPanel>
</Window>

User Control:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="35" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <StackPanel Grid.Row="0" Margin="5, 5, 5, 5" Orientation="Horizontal">
        <Button Content="New" Width="60" Command="{Binding NewCommand}"/>
        <Button Content="Remove" Width="60" Margin="10, 0, 0, 0" Command="{Binding RemoveCommand}" />
    </StackPanel>
    <DockPanel Grid.Row="1" Margin="5,5,5,5" LastChildFill="True" HorizontalAlignment="Stretch">
        <ListView x:Name="ListView" SelectionMode="Single" DockPanel.Dock="Top" ItemsSource="{Binding Entities}" SelectedItem="{Binding SelectedEntity}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" VerticalAlignment="Stretch">
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="auto" Header="Product" DisplayMemberBinding="{Binding Description}"/>
                </GridView>
            </ListView.View>
        </ListView>
    </DockPanel>
</Grid>

Could you please help me?

Thank you!

  • 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-06-07T23:13:27+00:00Added an answer on June 7, 2026 at 11:13 pm

    I’ve just inspected your User Control and the Listview docking is working just fine. You can verify layout in the designer by using background colours. Setting the listview’s background to blue shows it is using the available space.

    I believe the problem is with the layout in your main form, specifically the Stackpanel. These are notorious for layout issues, and from what I can tell you don’t need it. use the DockPanel as the high-level container rather than multiple dock panels. (This is what they’re for)

    <DockPanel>
        <Menu DockPanel.Dock="Top" >
            <MenuItem Header="Item 1" Command="{Binding Command1}"/>
            <MenuItem Header="Item 2" Command="{Binding Command2}"/>
            <MenuItem Header="Item 3" Command="{Binding Command3}"/>
        </Menu>
        <ScrollViewer Content="{Binding Content}" VerticalScrollBarVisibility="Disabled"
             HorizontalScrollBarVisibility="Disabled" DockPanel.Dock="Fill" />
    </DockPanel>
    

    This will put your menu at the top of the panel, and let your scroll viewer containing the user control (assumed) use up the remaining available space.

    Stack-panels are only good for arranging items within an area. If you want to use layout to allocate available space, use DockPanels or Grids.

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

Sidebar

Related Questions

I want to display some data in grid like control, in which every row
I have a ListBox control in WPF which contains items of variable height (predominantly
We have multiple lights in 10x10 grid each of which we can control intensity
I have a custom control which displays results of some operations. It is hidden
I have a user control which uses objects as inner properties (some code is
I have a control derived from System.Windows.Forms.UserControl which is placed in a customized grid.
I have a button which adds new row in grid view at button click
I have a UserControl which contains the following XAML: <GroupBox> <Grid> <Button x:Name=btn Content=Test/>
I have a control which has a button on it. All the button does
I have a control which is mounted within a form. I need to implement

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.