Overall steps... Requires WinAppSDK 1.0.0 Preview 3 or greater and you must COMPILE FOR x64 (there's a known bug where this doesn't work from x86 apps)
- Add code to find existing instance, and if found, redirect and kill current process using
System.Diagnostics.Process.GetCurrentProcess().Kill()
(the WinUI 3Exit()
method doesn't work) - Add code to handle the activation redirection
- Install the Microsoft.Windows.CsWin32 NuGet package
- Add the NativeMethods.txt file with two methods,
ShowWindow
andSetForegroundWindow
(the WinUI 3Activate
and AppWindowShow
methods don't work) - In the redirection event, call
ShowWindow
andSetForegroundWindow
Full code sample: https://github.com/andrewleader/RedirectActivationWinUI3Sample