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?