?
Solved

WPF: Using the expander control

Posted on 2014-03-03
2
Medium Priority
?
1,134 Views
Last Modified: 2014-03-04
I need to design a user control  that has an expander  at the top of the control that is used to reveal some details about the current page being displayed. Below the expander is a ListView control displaying the content.

This is an outline of the XAML I have right now:

<UserControl>
      <StackPanel>
            <Expander>
                   ... expander content
            </Expander>
            <ListView> .... </ListView>
      </StackPanel>
</UserControl>

Open in new window


The StackPanel is set for vertical mode and the ListView is stretched to fill the space left after the Expander. The issue is that the ListView does not fill the vertical space left.

To try and figure out the problem I made a test application that has a StackPanel with only a ListView in it and the same happens, the ListView does not fill the StackPanel vertically, in spite of being set to stretch.

Is there some way to overcome this please?
Sid.
0
Comment
Question by:Sid Price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Snarf0001 earned 2000 total points
ID: 39902119
StackPanel will only fill whatever space it actually needs.
A Grid with proper rowdefinitions will do what you need.  "Auto" will take whatever space it needs, "*" will take up the balance:

<UserControl>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Expander>
            ... expander content
        </Expander>
        <ListView Grid.Row="1">....</ListView>
    </Grid>
</UserControl>
0
 

Author Closing Comment

by:Sid Price
ID: 39903427
Perfect! Thank you so much I was unaware of the "Auto" setting, works just as required,
Sid.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question