Click here to Skip to main content
12,622,895 members (30,732 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# XAML WPF
So after I've done placing all the controls on the Grid, I realised it was a bad idea.

This is my XAML:

<Window x:Class="WordGuru.MainWindow"
        Title="MainWindow" Height="720" Width="1200" WindowStyle="None" >
        <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" >
                <Style TargetType="ListBoxItem">
                    <Setter Property="IsEnabled" Value="False"/>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="Red" />

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

Posted 3-Feb-13 13:13pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

Best regards
Espen Harlinn
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?

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, 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:
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100