FluentWPF icon indicating copy to clipboard operation
FluentWPF copied to clipboard

Incorrect behavior with WindowsFormsHost

Open m1024 opened this issue 6 years ago • 3 comments

There is no way to set solid color background to WindowsFormsHost control with the AcrylicWindow.

2 1

Any idea how to fix this?

m1024 avatar Jul 31 '19 08:07 m1024

Hi, @m1024

Thanks for the feedback. I'm not so familiar with interoperability between WPF & WinForms. I'd like to test WindowsFormsHost control. Please show me your code.

sourcechord avatar Aug 10 '19 07:08 sourcechord

Hi, @m1024

Thanks for the feedback. I'm not so familiar with interoperability between WPF & WinForms. I'd like to test WindowsFormsHost control. Please show me your code.

You just should create WinForms UserControl and put it in the xaml in WindowsFormsHost:

    <WindowsFormsHost Background="Black" Opacity="1" Grid.Row="1">
        <local:UserControl1></local:UserControl1>
    </WindowsFormsHost>

Full source code you can see here: https://github.com/m1024/FluentWpfTest

m1024 avatar Aug 12 '19 07:08 m1024

@m1024

Thank you for the information and full source code. I could reproduce it.

I think that it is caused by the airspace issue between WPF and WinForms. If so, it could be limitation of WPF.

The visual of WPF and other platforms can't be layered. (WindowsFormsHost control can't overlay and represents WPF's background.)

Furthermore, the background color of WindowsFormsHost is affected by the WPF Window. If you use AllowsTransparency="True" or customize Window with WindowChrome property, WindowsFormsHost controls become to have transparent background. (FluentWPF uses WindowChrome attached property internally.)

This is why the WindowsFormsHost controls become transparent.

I'm investigating this issue and finding a workaround. Please wait for a while.

sourcechord avatar Aug 14 '19 16:08 sourcechord