microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.15k stars 666 forks source link

Discussion: Legacy Pond (Legacy control container in XAML) for XAML Desktop #1833

Open reli-msft opened 4 years ago

reli-msft commented 4 years ago

Discussion: Legacy Pond (Legacy control container in XAML) for XAML Desktop

A long-lasting application may have many legacy controls that needs to be hosted inside XAML. Therefore, it would be valuable to create a legacy-in-XAML container, opposite to XAML Island, to allow WinUI to contain them and make these old controls work properly.

Austin-Lamb commented 4 years ago

Hi @reli-msft - thanks for the suggestion! We've been talking about the very same thing internally, and it's on our internal backlog already.

At the moment, we're spending pretty much all our time on WinUI 3, so that'll come before this feature - which means this'll be parked on the backlog for a good while.

To help us out, could you describe more about which legacy controls you'd like to host inside XAML, so we can capture your requirements? My thought at the moment is that we'd make a way to host an HWND to interop with as many legacy technologies as possible - but I could imagine we could build "interop helper libraries" to common technologies - much like how WPF has a way to more easily host Windows Forms controls, which is just a helper/wrapper atop WPF's HwndHost.

Are the legacy controls in your case from WPF? Windows Forms? MFC?

mdtauk commented 4 years ago

I imagine a HWND host control, could only work with an un-sandboxed WinUI 3 app

mariorancic01 commented 4 years ago

We also have similar problem. Right now we have WPF app that uses lot of c++ code through HwndHost control. We are planing to move Wpf app to WinUI and moving Xaml works great without problems, but what about HwndHost, is this going to be possible with WinUI3. In our case we are doing interoperability with DirectShow through HwndHost and right now in WinUI 2 , this is not possible. What will be realistic date to use HwndHost in WinUI3? Also is this new Xaml Window and Application like discussed at latest February WinUI Community call, could help or not?

dpierangeli commented 3 years ago

In our case we have a MFC control (yes, that's a very old application).

hansmbakker commented 3 years ago

I am curious about this from WinForms, have an old application I received which I am trying to modernise.

Currently looking at XAML islands. The hardest part is the custom painting (System.Drawing) code.

Also unsure what a good replacement for that would be, since in WinUI there is no Win2D support yet and also no SkiaSharp.

wjk commented 3 years ago

I also would want this. I am using windowless Rich Edit controls to render complex text layouts, but that control will only render into a raw HDC. Without the ability to host a raw WinForms control in the XAML tree that Rich Edit can use, I am forced to use multiple top-level Islands, which I understand is very buggy right now.

Edit: Check that. It turns out I can get an HDC out of a DirectX-based rendering infrastructure using ID2D1GdiInteropRenderTarget, but I don't know how easy that will be to integrate into a WinUI app. (The only way I know of to initialize Direct2D to draw into a HDC requires an HWND, and the docs are ambiguous as to what other kinds of render targets support ID2DGdiInteropRenderTarget.)