Solved

WPF: Using the expander control

Posted on 2014-03-03
2
1,051 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
2 Comments
 
LVL 22

Accepted Solution

by:
Snarf0001 earned 500 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now