Vincent
Vincent

Reputation: 3294

How to disable scaling for UWP apps

I'm designing uwp apps. My pc resolution is 1920 x 1080, 100% scale. All the elements are layout normal. But when running app on a screen 1920 x 1080, 125% scale, the elements are not in the right place and all are 1.25x bigger.

So how to disable scale under all resolutions, or is there any solutions?

Upvotes: 0

Views: 826

Answers (1)

user11362349
user11362349

Reputation:

I am giving you the simple example in which i am showing two buttons and one grid you can run this on any resolution the left and right hand side button always keep in same position and grid will change accordingly resolution size

   <Grid HorizontalAlignment="Stretch"  Margin="0,0,0,0" VerticalAlignment="Stretch" >
        <Grid.RowDefinitions>
            <RowDefinition Height="150"/>
            <RowDefinition Height="169*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150"/>
            <ColumnDefinition Width="113*"/>
            <ColumnDefinition Width="150"/>
        </Grid.ColumnDefinitions>
        <Button Content="Button" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,55,10,40" />
        <Button Content="Button" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,55,10,40" Grid.Column="2" />
        <Grid Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderBrush="Black" BorderThickness="2" Grid.RowSpan="2"/>
    </Gid>

your code sample

   <Grid HorizontalAlignment="Stretch"  Margin="0,0,0,0" VerticalAlignment="Stretch" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="945"/>
            <ColumnDefinition Width="945"/>
        </Grid.ColumnDefinitions>
        <TextBlock Text="Color"
            Margin="117, 84, 0, 0"
            FontSize="48"/>
        <Button Grid.Row="1" Content="Red" Width="500" Height="80" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" 
                Margin="445 30 0 0"
                />
        <Button Grid.Row="1" Grid.Column="1" Content="Yellow" Width="500" Height="80" 
                Margin="0 30 445 0"
                HorizontalAlignment="Center" VerticalAlignment="Center"/>


        <Grid Grid.Row="2" Grid.ColumnSpan="2"
            Margin="84 40 84 0" HorizontalAlignment="Stretch" 
              VerticalAlignment="Stretch" BorderBrush="Black" BorderThickness="2"/>
    </Grid>

Upvotes: 2

Related Questions