tyczj
tyczj

Reputation: 74066

Making XAML layout dynamic

I am new to using XAML and C# in general so this is probably an easy question but I have my XAML as so

<Page
x:Class="Tournament_Director_Windows.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Tournament_Director_Windows"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="LightGray">
    <Button  Style="{StaticResource AddAppBarButtonStyle}" Foreground="#FF094AB2" Click="onAddNewBowlerClick" HorizontalAlignment="Right" RenderTransformOrigin="0.4,0.508" Margin="0,10,115,679"/>
    <ListView Height="648" Width="377" HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="itemListView" ItemClick="itemListView_ItemClick" ItemsSource="{Binding}" IsItemClickEnabled="True" Margin="225,110,0,0">
        <ListView.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Name}"/>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
    <TextBlock TextWrapping="Wrap" Text="Bowlers" Height="54" Width="177" FontSize="50" Foreground="#FF094AB2" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="225,10,964,704"/>
    <Button  Style="{StaticResource RefreshAppBarButtonStyle}" Click="onSyncClick"  Background="#FFF8FCFD" HorizontalAlignment="Right" Foreground="#FF094AB2" BorderBrush="#FFFBF9F9" Margin="0,10,10,679"/>
    <ListView HorizontalAlignment="Left" Height="Auto" Width="220" Background="Silver" SelectionChanged="MenuListView_SelectionChanged">

        <!--<ListView.Resources> 
            <Style TargetType="ListViewItem">
                <Setter Property="Foreground" Value="#FF094AB2" />
                <Setter Property="FontSize" Value="30" />
                <Setter Property="Height" Value="75"/>
            </Style>
        </ListView.Resources>-->

        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="Foreground" Value="#FF094AB2" />
                <Setter Property="FontSize" Value="25" />
                <Setter Property="Height" Value="75"/>
                <Setter Property="Padding" Value="10"/>
            </Style>
        </ListView.ItemContainerStyle>

        <x:String>Bowlers</x:String>
        <x:String>Brackets</x:String>
        <x:String>Scores</x:String>
    </ListView>
    <ScrollViewer Height="Auto" HorizontalAlignment="Stretch" Width="754" Margin="602,110,0,10">

    </ScrollViewer>
</Grid>

my question is about the ScrollViewer at the end, I have it as a set width but what I want to do is have the width fill the rest of the screen from its set position next to my ListView so no matter what screen size you have it looks the same and there is not a big space if you have a bigger screen or it gets cut off because the screen is smaller.

How can I do that?

Upvotes: 0

Views: 457

Answers (1)

Alexey
Alexey

Reputation: 1904

Try to use <ColumnDefinitions> with width property "Auto" or "*" and <RowDefinitions> with height property "Auto" or "*" for grid. In this case you can manage what part of your content has permanent size and what part will resize with a window.

Upvotes: 1

Related Questions