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

Blur offset when using SizeToContent="WidthAndHeight" in AcrylicWindow #56

Closed
AntonKosenkoDX opened this issue Jul 2, 2019 · 3 comments
Labels

Comments

@AntonKosenkoDX
Copy link

изображение

@Barina
Copy link

Barina commented Jul 4, 2019

Same here. can't find a workaround.
It also not rendering properly at first. after resizing it renders the whole window/control. doesn't have anything to do with SizeToContent though..
Issue
Expected

@sourcechord
Copy link
Owner

Hi @BeautyRazor @Barina

Thanks for the feedback.
I recognized this issue.

But it is little a bit difficult to fix.
I'll try to fix it in future update.

@sourcechord
Copy link
Owner

This is famous bug in WPF.
When use WindowChrome with SizeToContent="WidthAndHeight", WPF can't calculate the exact window size.

<Window x:Class="WpfApp1.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"
        SizeToContent="WidthAndHeight"
        Title="MainWindow">
    <WindowChrome.WindowChrome>
        <WindowChrome GlassFrameThickness="-1"/>
    </WindowChrome.WindowChrome>
    <Grid Background="Beige" Width="300" Height="200">
        <TextBlock Margin="10"
                   HorizontalAlignment="Left"
                   VerticalAlignment="Top"
                   Text="TextBlock"
                   TextWrapping="Wrap" />
    </Grid>
</Window>

image

But I found a workaround for it.
The way is to call InvalidateMeasure method in OnContentRendered.

        protected override void OnContentRendered(EventArgs e)
        {
            base.OnContentRendered(e);

            if (this.SizeToContent != SizeToContent.Manual)
            {
                this.InvalidateMeasure();
            }
        }

In addition, it can be emmbeded in AcrylicWindow's implement.
So that, I'll try to fix it in next FluentWPF update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants