Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SizeToContent and ExtendsContentIntoTitleBar #1174

Open
Apskalle opened this issue Jul 26, 2024 · 2 comments
Open

SizeToContent and ExtendsContentIntoTitleBar #1174

Apskalle opened this issue Jul 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Apskalle
Copy link

Describe the bug

Not really a (wpfui-) bug but setting ExtendsContentIntoTitleBar to true and setting SizeToContent to WidthAndHeight gives the strange effect of the content being misaligned in the window, leaving a black area right and bottom, as described here

image

Since this rates to be common using FluentWindow, maybe a fix can be included there.

Meanwhile, a fix that seems to work but gives som flicker:
In the windows ContentRendered call

private void corewnd_ContentRendered(object sender, System.EventArgs e)
  {
      var firstrender = true;

      if (firstrender)
      {
          InvalidateVisual();
          firstrender = false;
      }
}

To Reproduce

Set FluentWindow ExtendsContentIntoTitleBar=true and WidthAndHeight=SizeToContent and add content.

Expected behavior

Normal content display

Screenshots

No response

OS version

Win 11 Pro

.NET version

8

WPF-UI NuGet version

4.0.3

Additional context

No response

@Apskalle Apskalle added the bug Something isn't working label Jul 26, 2024
@Apskalle
Copy link
Author

Apskalle commented Aug 3, 2024

Additional:

<ui:FluentWindow x:Class="WpfNet9App.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"
        xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
        xmlns:local="clr-namespace:WpfNet9App"
        mc:Ignorable="d"
        ExtendsContentIntoTitleBar="True"        
        SizeToContent="WidthAndHeight"         
        Title="MainWindow">
    <Grid>
        <Border Width="300" Height="300" Background="Yellow"/>
    </Grid>

</ui:FluentWindow>

In VS preview window:

image

When run:

image

@Apskalle
Copy link
Author

Apskalle commented Aug 23, 2024

The Wpf source shows MS have been looking at this, as far as I can tell w/o really fixing it

From comment in https://github.com/dotnet/wpf/tree/main/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Window.cs, line 2557

// We don't do anything that uses the Window styles below so we might as
// well close the using so that we update the new style to the hwnd.
// This change was made to solve a problem where SizeToContent.WidthAndHeight borderless
// windows where actually bigger than the content size. This was b/c of
// the fact that we didn't update the style of the hwnd before setting
// the RootVisual which inturn calls MeasureOverride on Window from
// where we calculating the non-client area size using the stale
// style bits from the hwnd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant