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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:45:11+00:00 2026-06-09T10:45:11+00:00

I have a window with this basic layout: <Window x:Class=GridStuffs.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow Height=350

  • 0

I have a window with this basic layout:

<Window x:Class="GridStuffs.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
    </Grid.RowDefinitions>
    <Button Grid.Row="0" Click="TopButtonClick" VerticalAlignment="Stretch">Top</Button>
    <Button Grid.Row="1" Name="_bottomButton">Bottom</Button>
</Grid>

Which is just displaying two buttons ‘top’ and ‘bottom’, each taking up equal vertical space in the window.

Clicking the top button executes the following:

private void TopButtonClick(object sender, RoutedEventArgs e)
{
    if (_bottomButton.Visibility == Visibility.Collapsed)
    {
        _bottomButton.Visibility = Visibility.Visible;
    }
    else
    {
        _bottomButton.Visibility = Visibility.Collapsed;
    }
}

…which toggles the Visibity of the bottom button between Collapsed and Visible.

What I want to happen is have the top button resize to fill the window when the bottom button is collapsed. What’s actually happening is the bottom button is hidden, but the top button retains it’s original size.

Question: What wpf/xaml magic do I have to do to have the top button expand to fill the window when the bottom button is collapsed?

  • 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-09T10:45:13+00:00Added an answer on June 9, 2026 at 10:45 am

    Set the top RowDefinition to Height="*", meaning it will take up all available space, and set the second RowDefinition to Height="Auto" meaning it will take up as much space as it needs to show its content,

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

    In the event that your 2nd Button’s height is not defined and should be 50% of the Grid’s height, I would use a converter to bind the Button.Height property to half of the parent Grid’s height

    <Button Height="{Binding ActualHeight, 
        RelativeSource={RelativeSource Grid}, 
        Converter={StaticResource HalfOfValueConverter}}" />
    

    If you’re interested, I actually have a MathConverter posted on my blog that I use for any kind of mathematical equations with a bound value.

    <Button Height="{Binding ActualHeight, 
        RelativeSource={RelativeSource Grid}, 
        Converter={StaticResource MathConverter},
        ConverterParameter=@VALUE/2}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a window which is like this <Window x:Class=pharmacy_Concept.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow Height=350
We have this situation: Window Keyboard ^ ^ | / ApplicationWindow so class Window
I have this basic javascript code: window.resizeTo(1000,800) set to run when the page loads
I'm trying to create a basic version of this example in CoffeeScript: http://davidsulc.com/blog/2012/04/15/a-simple-backbone-marionette-tutorial/ .
I have trivial window: this.window = Ext.widget('window', { title: 'Find', closeAction: 'hide', width: 300,
I have other-window.xaml file and trying to open this from window.xaml on button click.
I have this problem: After instantiating this Window, open all nested expanders on the
I have a window with 3 radiobuttons like this(removed all non interesting props): <Control
I have a window that uses a viewmodel. This screen contains 2 listviews on
Suppose I have a javascript object like this: window.config config.UI = { opacity: {

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.