Skip to content

How should I focus an AppWindow? #1746

Answered by andrewleader
JohnCido asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @JohnCido, the AppWindow APIs don't support bringing the window to the foreground (I assume you are trying to bring your window to the foreground/front as a result of an app launch redirection or some other event that should bring your window to the foreground). The Show() API unfortunately doesn't do that.

Here's how to bring a window to the foreground from a C# desktop app...

1. Install Microsoft.Windows.CsWin32 NuGet package

2. Add NativeMethods.txt file

This file specifies what C++ Win32 APIs you want projected into C#. We only need two APIs, so the file contents should simply be...

SetForegroundWindow
ShowWindow

3. Bring your window to the foreground

    // Bring the window to th…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@JohnCido
Comment options

@martibravo
Comment options

Comment options

You must be logged in to vote
2 replies
@JohnCido
Comment options

@andrewleader
Comment options

Answer selected by andrewleader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants