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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:14:52+00:00 2026-05-25T17:14:52+00:00

I do have a Grid with two columns and two rows. In the first

  • 0

I do have a Grid with two columns and two rows. In the first column, first row I do have this:

<StackPanel  Orientation="Vertical" HorizontalAlignment="Stretch" Grid.ColumnSpan="1" Grid.Row="0" Grid.Column="0">
    <StackPanel  Orientation="Horizontal" Height="25" HorizontalAlignment="Stretch">
        <Label Content="Text:"/>
        <TextBox Name="TB_Text" HorizontalAlignment="Stretch" MinWidth="120" />
        <Button Name="BT_TextApply" Content="Apply" Width="75" HorizontalAlignment="Right" Click="BT_TextApply_Click" />
    </StackPanel>
</StackPanel>

I have “rows” (Horizontal StackPanels within a Vertical StackPanel) consisting of a Label, a Textbox and a button that belongs together.

The StackPanels got the attribute HorizontalAlignment="Stretch" so that they use the complete space within their Grid cell, this is OK.

But now I want my three elements also to fill the complete available space of the StackPanel, but I don’t get it to work.

Current behaviour

  • The Label has no width it occupies the space that the text in content needs, this is at the moment fine.
  • The Textbox has a minimum width and gets bigger when I fill it with text,
  • the button is on the right of the Texbox and is moved to the right when the TextBox gets bigger and disappears when it is moved outside the StackPanel

Wanted behaviour

  • The Label has no width it occupies the space that the text in content needs, this is at the moment fine.
  • The Button should have a fixed width (no problem) and should stick to the right border of my StackPanel, this is not working
  • The TextBox should use the rest of the space in between and not more, even when filled with more text than fits in.

Is there something like a “max” attribute for my TextBox dependend on the size of the StackPanel?

  • 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-05-25T17:14:53+00:00Added an answer on May 25, 2026 at 5:14 pm

    Thanks stema. I didn’t have the time to try it so I wasn’t sure if that would work or not.

    Instead of a StackPanel, have you tried using a DockPanel with last child fill set to true? If you dock the label left and the button right. Then ensure the textbox is the last child element of the dockpanel, I would think the size of the textbox would fill the remaining space if its HorizontalAlignment is set to stretch.

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

Sidebar

Related Questions

We have two textBlocks like this: (we used .NET FW 3.0) <TextBlock Grid.Column=0 Name=tabName
In my grid I have data in two columns same for couple of rows.
I have a grid with two columns and multiple rows, each cell containing a
I have a flex datagrid with 3 columns. The first column contains the image
I have a datagrid that displays items with two columns of text row data
I have a grid with 100 columns and 100 rows. I want to draw
I have a grid view with three columns and five rows with text item
I have two different grid controls on the same form. They share the same
I have a grid that has multiple rows. I want to hide/show one of
I have a grid in a XAML file in a WPF project. This MainGrid

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.