HC1122
HC1122

Reputation: 414

Fixing the position of elements in Visual Studio XAML GUI

I am trying to learn how to work in Visual Studio 2013 (WPF Application) with making a simple XAML GUI. Inside GRID I was using some basic elements like TextBlock, TreeView, ListView, etc... Now here appears my problem. At the beggining I have made my "workspace" on resolution 350*525. I was draging the elements around that workspace, to place them in a perfect spot & order. Everything fits in that window as you can see on my screenshot: https://i.sstatic.net/nnZzU.png

But when I am trying to resize my window, everything is messed up like that: https://i.sstatic.net/PvCXj.png How I am able to fix it? I want that everything fits with window no matter how much you resize it, text should stay inside border.

I hope you guys understand my question and that someone is able to help me.

Thanks a lot!

Upvotes: 1

Views: 1082

Answers (1)

Dhru 'soni
Dhru 'soni

Reputation: 1058

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <StackPanel Orientation="Vertical">
        <TextBlock Text="Xaml Gui" FontSize="25"/>
            <TextBlock Text="Try With this"/>
        </StackPanel>
        <StackPanel Grid.Row="1" Orientation="Vertical">
            <TreeView/>
            <TreeView/>
        </StackPanel>
        <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Vertical">
            <ListBox Height="50" Width="100"/>
            <ListBox Height="50" Width="100"/>
        </StackPanel>
        <StackPanel Grid.Row="1" Grid.Column="2">
            <TextBlock Text="Put Your things here" FontSize="25"/>
            <TextBlock Text="Try it now " FontSize="25"/>
        </StackPanel>
    </Grid>

Upvotes: 0

Related Questions