Troubles with SwitchPanel and Windows Form interop

Views for WPF Forum

Posted 10 years ago by 7Alpha7
Version: 13.2.0592
Avatar

Hello,

I use a SwitchPannel with AnimatedWrapPanel option. On some ListBoxItem I display a Windows Form content through a WindowsFormsHost. This works fine, except when there is animation on the SwitchPannel, either when an item is resized or when the complete list is resized, causing a different items arrangement. The items are moving here or there but the Windows Form content does not follow the movement and stay stucked at the original place for a while. Frequently, I need to mouse over the mouse to make it move to its expected location.

Do you have any idea of what is going on ?

Thank you.

Comments (4)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

I'm honestly not sure why that would happen.  WPF / WinForms interop in general is sometimes somewhat flakey.  There's the common airspace issue (WinForms content is always above WPF content in the same Window), issues with focus tracking between the platform, etc.  I'm not sure I would recommend using interop controls like WinForms controls in animated areas of your app.

I wonder if you could call InvalidateVisual() or InvalidateMeasure() after this happens to force the WindowsFormsHost to redraw.  But based on what you said with it staying where it was, it sounds like that might not help since it seems like there is a positional issue.  By the fact that you say that it corrects iteself following the mouse over, it seems like we have passed the correct info but WPF just didn't reposition it properly.


Actipro Software Support

Posted 10 years ago by 7Alpha7
Avatar

I have thougth to something like that, but I don't know what event to track for the positionning. I am not deep in WPF so I need a bit help. Since the WindowsFormsHost is inside a UIElement, I thought I could subscribe to a Parent event, but I am not sure which one to choose that would be fired on repositionning / resizing.

However, I doubt it would work, since sometimes it works without it, and sometimes not... 

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

You might need to inherit the Panel doing the arranging and override the ArrangeCore method to put your logic there.  That or possibly handle the item's LayoutUpdated event.  I haven't really tried using that event before but I believe it fires on the item after it is arranged.


Actipro Software Support

Posted 10 years ago by 7Alpha7
Avatar

Allright, I'll try sothming like that and I'll let you know about it. Thank you.

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.