Solved

WPF: Using the expander control

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Event ID 10010 3 80
Using an Atomic update intermittently results in duplicates 14 36
WPF MainWindow update textbox from another class... 6 205
Visual Studio Debugging 3 165
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 …
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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