Solved

WPF: Using the expander control

Posted on 2014-03-03
2
1,076 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

831 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