ModernWpf icon indicating copy to clipboard operation
ModernWpf copied to clipboard

[BUG] Rendering bug when `SizeToContent` is set.

Open Ucag opened this issue 3 years ago • 3 comments

I have code like this:

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        x:Class="ImageTemplateEditor.Views.MainWindow"
        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:local="clr-namespace:ImageTemplateEditor"
        xmlns:views="clr-namespace:ImageTemplateEditor.Views"
        xmlns:ui="http://schemas.modernwpf.com/2019"
        mc:Ignorable="d"
        ui:WindowHelper.UseModernWindowStyle="True"
        SizeToContent="WidthAndHeight"
        Title="example">
    <ui:Frame 
        x:Name="ContentFrame">
        <ui:Frame.ContentTransitions>
            <ui:TransitionCollection>
                <ui:NavigationThemeTransition>
                    <ui:DrillInNavigationTransitionInfo/>
                </ui:NavigationThemeTransition>
            </ui:TransitionCollection>
        </ui:Frame.ContentTransitions>
        <ui:Frame.Content>
            <views:Welcome/>
        </ui:Frame.Content>
    </ui:Frame>
</Window>

its page is dynamically changing.

If run it, black square would appear. rendering_bug

After some trying, if I remove the line ui:WindowHelper.UseModernWindowStyle="True", the black square won't show up again.

I guess there is something to do with the style calculation.

Ucag avatar Aug 02 '21 00:08 Ucag

FYI, I am experiencing the same issue. If I allow resize on the window, as soon as I drag the corner the layout updates and the problem goes away. Not really a solution but I thought it might be useful info.

Initial view (note the position of the drag handle): Screenshot 2021-11-26 185737

As soon as I grab the handle the window layout updates: Screenshot 2021-11-26 185808

ms162223 avatar Nov 27 '21 01:11 ms162223

Hi,

I too am seeing this behavior with SizeToContent set. The following workaround does seem to address the UI glitch:

SourceInitialized += (s, a) =>
{
  Dispatcher.Invoke(InvalidateVisual, DispatcherPriority.Input);
};

developernotes avatar Dec 14 '21 18:12 developernotes

This works for deleting lines. But this fix makes the dialog appear larger at the bottom compared to the original. In my case, about 40 px white space was added below.

AsaharaHiroshi avatar Aug 23 '23 06:08 AsaharaHiroshi