TonyW
TonyW

Reputation: 786

Stretch TextBox in StackPanel

This is the current XAML i'm using to do this... and for the life of me cannot figure out how to expand the textbox to fill the entire column. Could anyone please guide me in the correct direction?

Thank you in advance!

Picture of issue

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

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="200" />
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <!--ROW 0-->
    <TextBlock Text="DOMAIN:"/>
    <!--ROW 1-->
    <Separator Grid.Row="1" Grid.ColumnSpan="2"/>

    <!--ROW 2-->
    <TextBlock  Text="Connection credentials:" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="2" Grid.Column="0"/>
    <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1">
        <Button Content="EDIT" Style="{DynamicResource SquareButtonStyle}" Width="80" Margin="0,0,10,0"/>
        <TextBlock x:Name="CurrentCredentialslbl" Text="Connect as:" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
    </StackPanel>

    <!--ROW 3-->
    <TextBlock  Text="Find accounts in domain:" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="3" Grid.Column="0"/>
    <StackPanel Orientation="Horizontal" Grid.Row="3" Grid.Column="1">
        <TextBox />
        <Button Content="Browse" Style="{DynamicResource SquareButtonStyle}" Width="80" Margin="10,0,0,0"/>
    </StackPanel>

    <!--ROW 4-->
    <CheckBox  Content="Only search in this container" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="4" Grid.Column="0"/>
</Grid>

Upvotes: 2

Views: 3263

Answers (1)

ASh
ASh

Reputation: 35646

Grid with 2 columns instead of StackPanel should fit perfectly

<Grid Grid.Row="3" Grid.Column="1">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>

    <TextBox />
    <Button Grid.Column="1" 
            Content="Browse" 
            Style="{DynamicResource SquareButtonStyle}" 
            Width="80" Margin="10,0,0,0"/>
</Grid>

Upvotes: 4

Related Questions