Resolution Independent WPF Application

I am developing a database system that should be resolution independent, some use screens that still work at 1024 x 768, some use screens with a resolution of 1920 x 1080, and others use everything in between.

I did not do much work with WPF before I just start and try to bow my head to height, width and alignment.

Currently, I have one main window in which there is a grid in which at the top there is a line for the shortcut and some navigation buttons, as well as the time and username of the user. have a second line below the one that contains the frame into which I load the pages for the main navigation of the program.

On the pages, I mainly use the grid layout, and sometimes the stack panel. One of the biggest problems I encountered is this one:

enter image description here

At low resolutions, this is a common occurrence where, like at higher resolutions, the buttons look good,

enter image description here

This is the XAML code for the buttons in their parent grid;

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Button Content="HR" Margin="10"  Click="RunHrSystem" FontSize="18.667" />
        <Button Content="Companies" Margin="10" Click="RunCompSystem" FontSize="18.667" Grid.Row="1" />
        <Button Content="People" Margin="10" Click="RunPeopleSystem" FontSize="18.667" Grid.Row="2" />
        <Button Content="IT Management" Margin="10" Click="RunITManagementSystem" FontSize="18.667" Grid.Row="3"/>
        <Button Content="Sales" Margin="10" FontSize="18.667" Grid.Row="4" />
        <Button Content="Buying" Margin="10" FontSize="18.667" Grid.Row="5" />
        <Button Content="Estimating" Margin="10" FontSize="18.667" Grid.Row="6"/>
        <Button Content="Design" Margin="10" FontSize="18.667" Grid.Row="7"/>
    </Grid>

Is there something obvious I'm doing wrong here that prevents the buttons from resizing to a lower resolution? As I said, I get this in my entire program when using buttons, as well as in the form of a rectangle and in some situations shortcuts, where the lower part of the label is also reduced.

+4
source share
2 answers

RowDefinitions *, . , , .

, RowDefinition . .

<RowDefinition Height="Auto"/>

ScrollViewer, , , .

<ScrollViewer>
    <Grid>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        ...

StackPanel.

<ScrollViewer>
    <StackPanel>
        <Button ...
+5

, . . , . , - , * RowDefinitions , .

+1

Source: https://habr.com/ru/post/1613468/


All Articles