0

Good day!

How to composite wpf window-

i have MenuItem, one big TextBox and one Button.

MenuItem shoud resize when user resize window, TextBox-the same thing, but Buttn should stay at place.

I try to do it, but button resezes or "go away" when user resize window:

<Grid>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="80*"></ColumnDefinition>
        <ColumnDefinition Width="20*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="8*"></RowDefinition>
        <RowDefinition Height="92*"></RowDefinition>

    </Grid.RowDefinitions>

    <Menu Grid.Row="0" Grid.ColumnSpan="2" Margin="0,0,10,0" HorizontalAlignment="Stretch">

        <MenuItem Header="Settings" Height="24">
            <MenuItem Header="Load" Click="MenuItem_Click"/>
            <MenuItem Header="Close" Click="MenuItem_Click_1"/>
        </MenuItem>

    </Menu>

    <Grid Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
        <ScrollViewer Margin="0,0,-10,0">
            <TextBox HorizontalAlignment="Stretch" Name="tBOutput"  TextWrapping="Wrap" AcceptsReturn="True" Text="TextBox" VerticalAlignment="Stretch"  ScrollViewer.VerticalScrollBarVisibility="Auto"/>

        </ScrollViewer>


    </Grid>

    <Grid Grid.Row="1" Grid.Column="1" ShowGridLines="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="200" MinWidth="100" MaxHeight="500" MaxWidth="200" Margin="5,10,-2,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="13*"/>
            <ColumnDefinition Width="7*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="20*"></RowDefinition>
            <RowDefinition Height="80*"></RowDefinition>
        </Grid.RowDefinitions>
        <Button Name="startBtn" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Start!" Click="startBtn_Click" Margin="10,10,0,0" Grid.ColumnSpan="2" Height="55" Width="90" />

    </Grid>

</Grid>

1 Answer 1

1

If i clear recognize you, you can try something like this:

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="80*"></ColumnDefinition>
        <ColumnDefinition Width="120"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="8*"></RowDefinition>
        <RowDefinition Height="92*"></RowDefinition>

    </Grid.RowDefinitions>

    <Menu Grid.Row="0" Grid.ColumnSpan="2" Margin="0,0,10,0" HorizontalAlignment="Stretch">

        <MenuItem Header="Settings" Height="24">
            <MenuItem Header="Load" />
            <MenuItem Header="Close" />
        </MenuItem>

    </Menu>

    <Grid Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
        <ScrollViewer Margin="0,0,-10,0">
            <TextBox HorizontalAlignment="Stretch" Name="tBOutput"  TextWrapping="Wrap" AcceptsReturn="True" Text="TextBox" VerticalAlignment="Stretch"  ScrollViewer.VerticalScrollBarVisibility="Auto"/>

        </ScrollViewer>


    </Grid>

    <Grid Grid.Row="1" Grid.Column="1" ShowGridLines="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5,10,-2,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="13*"/>
            <ColumnDefinition Width="7*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="60"></RowDefinition>
            <RowDefinition Height="80*"></RowDefinition>
        </Grid.RowDefinitions>
        <Button Name="startBtn" HorizontalAlignment="Left" VerticalAlignment="Top" Content="Start!" Margin="10,10,0,0" Grid.ColumnSpan="2" Height="55" Width="90" />

    </Grid>

</Grid>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.