0
votes

I have a WPF application. To make the full screen visible on all screen sizes, I have implemented MinHeight, MinWidth & HorizontalAlignment="Stretch" VerticalAlignment="Stretch" in Window & Containers too. I am facing some problems when the app runs on Lower Resolution screens. The window gets cut from the right side of the screen - this doesn't show Min, Max, Close btns also on top right.

If I add layout code in then the window is proper in all resolutions, but it makes blank space above the Menubar and below end. On removing , their is no space and all is well, but right side gets cut in Low Resolution screens. And with ViewBox, space above and below the layout. My XML code is like follows :

CODE UPDATED

    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!-- MENU BAR -->
        <Menu Grid.Row="0" x:Name="myMnus" VerticalAlignment="Top" Cursor="Hand" HorizontalAlignment="Stretch" IsMainMenu="True" Grid.ColumnSpan="2">
           .............
        </Menu>

        <ToolBarTray HorizontalAlignment="Stretch"  Background="White" Margin="0,19,114,0" VerticalAlignment="Top" Grid.ColumnSpan="2"  >
             ..............
        <ToolBarTray>

        <TabControl Grid.Row="1" Name="tabControl1" HorizontalAlignment="Left"  Margin="0,3,0,0" VerticalAlignment="Top" 
                TabStripPlacement="Bottom" Grid.RowSpan="2" BorderThickness="4,25,4,1" FontSize="13">
        </TabControl>

        <TabControl Grid.Row="2" Name="tabControl4" HorizontalAlignment="Left" Margin="0,323,0,0" VerticalAlignment="Stretch" 
                TabStripPlacement="Bottom" BorderThickness="4,25,4,1"  FontSize="13" Background="White" Width="227">
        </TabControl>

        <TabControl TabStripPlacement="Bottom" MinHeight="415" MinWidth="480" VerticalAlignment="Stretch"  HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="1" Name="tabChildContainer" Margin="227,3,207,0" BorderThickness="4,25,4,1" Grid.RowSpan="2" >

        </TabControl>

    </Grid>

I thought by using Stretch in HorizontalAlignment and VerticalAlignment along with MinWidth and MinHeight, that it would occupy all available space horizontally and Vertically. But tabChildContainer TabControl doesn't go to the right end corner which it should go based on the code.

1
I removed HorizontalAlignment="Stretch" VerticalAlignment="Stretch" of tabControl1 and got rid of the Width expansion problem. Now, need just 1 thing - Both the tabControl1 & tabControl4 be of same height.Tvd

1 Answers

2
votes

This is where your problem starts:

<Grid.ColumnDefinitions>
    <ColumnDefinition Width="762.976"/>
    <ColumnDefinition Width="751.024"/>
    <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

Anytime that you set exact pixel sizes in your UI, you're asking for exactly these kinds of problems. Setting exact sizes for sections of your application was more of a WinForms thing... WPF has numerous controls that can resize your content for you... you're using one, the Grid... just incorrectly.

Secondly, it is very unusual to use a ViewBox on your whole UI... it is not going to help you. Your best bet is to simply remove it and all of your hard-coded dimensions and make full use of the "*" and "Auto" values in your Grid. When the controls resize themselves (or a Grid resizes them) in this way, it really doesn't matter what resolution a user is using.