Click here to Skip to main content
Rate this: bad
good
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"
        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 3-Feb-13 12:13pm

1 solution

Rate this: bad
good
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
  Permalink  
Comments
Member 9808042 at 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 at 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 at 3-Feb-13 19:00pm
   
Thanks! I just saw it, I think I know what to do now!
Espen Harlinn at 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 at 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
0 OriginalGriff 389
1 Sergey Alexandrovich Kryukov 362
2 CPallini 130
3 Abdul Samad KP 125
4 Richard MacCutchan 110
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,680
2 CPallini 4,850
3 George Jonsson 3,454
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2014
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