Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So after I've done placing all the controls on the Grid, I realised it was a bad idea.

This is my XAML:

C#
<Window x:Class="WordGuru.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="720" Width="1200" WindowStyle="None" >
    <Grid>
        <Label Content="Game Word" HorizontalAlignment="Left" Margin="90,57,0,0" VerticalAlignment="Top" Height="64" Width="221" FontSize="48" FontFamily="Agency FB" FontWeight="Bold"/>
        <Label Content="Find Word" HorizontalAlignment="Left" Margin="112,126,0,0" VerticalAlignment="Top" Height="64" Width="173" FontSize="48" FontFamily="Agency FB" FontWeight="Bold"/>
        <Image Name="Smiley" HorizontalAlignment="Left" Height="256" Margin="311,232,0,0" VerticalAlignment="Top" Width="256" Source="RightSmile.png"/>
        <TextBox Name="GameWord" HorizontalAlignment="Left" Height="64" Margin="311,56,0,0" TextWrapping="Wrap" Text="ASDOJENALFJ" VerticalAlignment="Top" Width="327" FontFamily="Agency FB" FontSize="48" BorderBrush="Black" BorderThickness="4" IsReadOnly="True" />
        <TextBox Name="WordInput" HorizontalAlignment="Left" Height="64" Margin="311,125,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="327" FontFamily="Agency FB" FontSize="48" BorderBrush="Black" BorderThickness="4" KeyDown="WordInput_KeyDown" CharacterCasing="Upper"/>
        <ListBox Name="CorrWord" HorizontalAlignment="Left" Height="496" Margin="712,57,0,0" VerticalAlignment="Top" Width="334" BorderBrush="Black" BorderThickness="4" FontFamily="Agency FB" FontSize="36" >
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="IsEnabled" Value="False"/>
                    <Style.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="Red" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
        <TextBox Name="CountDown" Height="57" Margin="394,496,731.6,0" TextWrapping="Wrap" VerticalAlignment="Top" BorderBrush="White" FontFamily="Agency FB" FontSize="56" FontWeight="Bold" Text="Time" IsReadOnly="True" removed="{x:Null}" BorderThickness="0"/>
        <TextBox Height="57" Margin="112,496,784.6,0" TextWrapping="Wrap" Text="Time remaining:" VerticalAlignment="Top" BorderBrush="White" FontFamily="Agency FB" FontSize="48" IsReadOnly="True" removed="{x:Null}" BorderThickness="0" FontWeight="Bold"/>
        <ProgressBar Name="TBar" Value="30" Maximum="30" HorizontalAlignment="Left" Height="48" Margin="90,597,0,0" VerticalAlignment="Top" Width="956"/>
    </Grid>
</Window>


How should I do now to make it automatically resize depending on window size? I don't know where to start...

Thanks!
Posted

1 solution

You could use a ScaleTransform, have a look at Ivo Manolov's UI Scaling (UI Zooming) with WPF[^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Member 9808042 3-Feb-13 18:52pm    
Hi Espen!

Thanks for you answer!

Can I use that, instead of a scrollbar, somehow bind it with the window size? I still don't get much reading that article. Can you give me a small example how to use that technique in my case?

Thanks!
Espen Harlinn 3-Feb-13 18:55pm    
Below the blog article, there is a small icon that looks like a folder - use that to download the ScalableUI.zip, which contains the source code for the example.
Member 9808042 3-Feb-13 19:00pm    
Thanks! I just saw it, I think I know what to do now!
Espen Harlinn 3-Feb-13 19:03pm    
Brilliant, hopefully this will solve your problem - the alternative is to redesign the UI, or perhaps use a ScrollViewer: http://msdn.microsoft.com/en-us/library/ms750665.aspx
Member 9808042 4-Feb-13 13:58pm    
I ended up redesigning the UI, what I tried didn't work as I wanted. But I've learned alot though!

Please check my coming question, I think it's a hard one =( Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900