MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.32k stars 2.45k forks source link

MetroWindow Height And Width Includes Title Bar #2690

Closed bloritsch closed 4 years ago

bloritsch commented 8 years ago

What steps will reproduce this issue?

Create content that is at a specific size, and then adjust the min/max and normal height width directly at that size.

Vertical position cuts off the bottom by the same distance as the height of the title bar.

This is most likely due to creating the bar within what WPF consider's the window's space. May require new properties like ContentMinWidth, ContentMinHeight, etc. so the adjustments can be made for the actual widnow height/width.

Expected outcome

MinHeight, MaxHeight, Height properties reflect the content of the window (like it does with a normal window)

Environment

Evangelink commented 5 years ago

There might be something I am missing but I have the same behavior for a MahApps window and a regulard WPF window (the title height bar is different but same principle applies).

WPF Window example:

<Window x:Class="WpfApp4.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="MainWindow"
        Width="900"
        Height="600">
    <Border BorderBrush="Blue" BorderThickness="40" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
             Width="900"
             Height="600">
        <Grid Background="Yellow" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
    </Border>
</Window>

image

MahApps Window example:

<Controls:MetroWindow x:Class="MetroDemo.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                      Title="MahApps.Metro - Demo Application"
                      Width="900"
                      Height="600"
                      NonActiveGlowBrush="#CDFF0000"
                      ShowIconOnTitleBar="True"
                      WindowStartupLocation="CenterScreen"
                      mc:Ignorable="d">

    <Border BorderBrush="Blue" BorderThickness="40" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
            Width="900"
            Height="600">
        <Grid Background="Yellow" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
    </Border>
</Controls:MetroWindow>

image

Am I missing something?

cc @bloritsch

timunie commented 5 years ago

Isn't there the SizeToContent Property for this? https://docs.microsoft.com/en-us/dotnet/framework/wpf/app-development/how-to-automatically-size-a-window-to-fit-its-content

Happy Coding Tim

Evangelink commented 5 years ago

@timunie I am actually trying to understand what @bloritsch meant because with my test I see that MahApps MetroWindow behavior is the same as classic WPF Window.

bloritsch commented 5 years ago

Considering I haven't worked on the project referred to in 3 years, I'm going to have to go on faulty memory. If I recall correctly:

Unfortunately, I haven't worked on a WPF app, much less a MahApps app in roughly 3 years when I wrote this issue up.

In my case I had images in the background (i.e. mapping) library. It's pretty obvious when Antarctica looks different.

punker76 commented 4 years ago

I’m closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on for so long, then it seems no one has the time to implement this.

Please reopen if you still encounter this issue with the latest stable version and then please use the issue template.

If you have enough time then it would be nice to test this issue against the latest alpha version (availabe via NuGet and appveyor).

Thank you! 🙏