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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:21:07+00:00 2026-06-15T19:21:07+00:00

I have a WPF application which layout consists of 3 rows in a top

  • 0

I have a WPF application which layout consists of 3 rows in a top level Grid.

I want the middle row to use up the space it needs (the maximum space it needs is limited but depends on the width of the window).
The bottom row shall use up the remaining space.
The tricky part is the top row.
Its size can vary depending on a button which toggles the visibility of a large part of the content. I want it to use at most 50% of the height but not more than it really needs.
The following XAML describes what I want to accomplish:

    <Grid.RowDefinitions>
        <!-- neither "1*" nor "Auto" fully meets my needs -->
        <RowDefinition Height="Min(1*,Auto)"></RowDefinition>

        <RowDefinition Height="Auto"></RowDefinition>

        <RowDefinition Height="1*"></RowDefinition>
    </Grid.RowDefinitions>

The rows are:

  1. WrapPanel
  2. WrapPanel
  3. TextBox

if this is important.

  • 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-15T19:21:08+00:00Added an answer on June 15, 2026 at 7:21 pm

    If I understand it right, you could probably use Auto and then bind the MaxHeight attribute to the Height of the Grid. Maybe something like this:

    MaxHeightConverter.cs:

    public class MaxHeightConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
                throw new ArgumentException("MaxHeightConverter expects a height value", "values");
    
            return ((double)value / 2);
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    

    MyWindow.xaml:

    ...
    xmlns:converters="clr-namespace:MyApp.Namespace"
    ...
    <Window.Resources>
        <converters:MaxHeightConverter x:Key="MaxHeightValue" />
    </Window.Resources>
    
    <Grid x:Name="root">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
        </Grid.RowDefinitions>
    
        <WrapPanel >
            <WrapPanel.MaxHeight>
                <Binding Converter="{StaticResource MaxHeightValue}" ElementName="root" Path="ActualHeight" />
            </WrapPanel.MaxHeight>
        </WrapPanel>
    </Grid>
    ...
    

    Hope this helps.

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

Sidebar

Related Questions

Let's say I have a WPF application which makes use of the MVVM pattern.
I have a small wpf application which I want only the registered users of
I have a WPF application in which I use entity framework with mysql connector/net
I have a WPF application in which I'm trying to use Entity Framework 4.1
I have a WPF application which connects to a remote database over internet and
I have an XBAP WPF application which displays various pages inside of a Frame.
I have a C# WPF application which uses Excel interop libraries to generate and
I have created a wpf application into which I have added a user control
I have a DataGrid in a WPF application which has for its ItemsSource a
In my WPF application I have a Canvas in which I do some drawing.

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.