Window animation interferes with WindowsFormsHost positioning #1835

Closed
barbeque opened this Issue Mar 11, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@barbeque

When you put a WindowsFormsHost inside a Metro window, sometimes the WinForms control will occasionally 'hang' in space after the introductory animation has completed and only move once an event (such as hovering over the 'close' box or tabbing out of the MaskedTextBox) has been processed.

image

The actual control in question doesn't seem to matter; I've experienced it with Button, MaskedTextBox and CheckedListBox off the top of my head. It also happens if the WindowsFormsHost is located inside of a StackPanel or even the root Content control, not just the nested GroupBox described in the example XAML.

The test XAML to produce this window is:

    <metro:MetroWindow x:Class="MetroDemo.DemoWindow2"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
            xmlns:wfh="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
            Title="Demo window 2" Height="500" Width="400">
        <DockPanel LastChildFill="True">
            <StackPanel Orientation="Vertical" DockPanel.Dock="Bottom">
                <GroupBox Header="WinForms Controls">
                    <StackPanel Orientation="Vertical">
                        <WindowsFormsHost Width="100" HorizontalAlignment="Left">
                            <wfh:MaskedTextBox Mask="00/000/0000"/>
                        </WindowsFormsHost>
                    </StackPanel>
                </GroupBox>
            </StackPanel>
        </DockPanel>
    </metro:MetroWindow>

I believe it is animation related because setting WindowTransitionsEnabled to false fixes the problem.

I am using v1.1.2.0, grabbed from NuGet yesterday. OS is Windows 8.1 x64.

@punker76 punker76 added the jump in label Oct 23, 2015

@punker76 punker76 added the help wanted label Nov 9, 2015

@kjeremy

This comment has been minimized.

Show comment
Hide comment
@kjeremy

kjeremy Jan 29, 2016

I see this too on Windows 7

kjeremy commented Jan 29, 2016

I see this too on Windows 7

petvetbr added a commit to petvetbr/MahApps.Metro that referenced this issue Mar 2, 2016

@punker76 punker76 added this to the 1.5.0 milestone Apr 3, 2017

@punker76 punker76 closed this in 6a97de2 Apr 3, 2017

@punker76

This comment has been minimized.

Show comment
Hide comment
@punker76

punker76 Apr 3, 2017

Member

@barbeque I added a TransitionCompleted event to MetroContentControl and WindowTransitionCompleted event to MetroWindow which will be fired after the loaded Storyboard is completed. So you can subscribe to this event and can fire InvalidateVisual() (@petvetbr suggested this in #2394). This will be available in 1.5.0.
/cc @kjeremy

Member

punker76 commented Apr 3, 2017

@barbeque I added a TransitionCompleted event to MetroContentControl and WindowTransitionCompleted event to MetroWindow which will be fired after the loaded Storyboard is completed. So you can subscribe to this event and can fire InvalidateVisual() (@petvetbr suggested this in #2394). This will be available in 1.5.0.
/cc @kjeremy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment