Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old window gains focus and moves to foreground when opening new window in NavigationView.ItemInvoked #10272

Open
Scighost opened this issue Jan 5, 2025 · 0 comments
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@Scighost
Copy link

Scighost commented Jan 5, 2025

Describe the bug

When handling the NavigationView.ItemInvoked event to open a new window, the old window unexpectedly regains focus and moves to the foreground after the new window is shown. This disrupts the user experience as the old window should remain in its current state and not interfere with the new window. However, this issue does not occur when opening a new window inside the NavigationViewItem.Tapped event.

Steps to reproduce the bug

<Window x:Class="App.MainWindow">
    <NavigationView ItemInvoked="NavigationView_ItemInvoked">
        <NavigationView.PaneHeader>
            <NavigationViewItem Content="Tapped"
                                Icon="Accept"
                                Tapped="NavigationViewItem_Tapped" />
        </NavigationView.PaneHeader>
        <NavigationView.MenuItems>
            <NavigationViewItem Content="ItemInvoked" Icon="Cancel" />
        </NavigationView.MenuItems>
    </NavigationView>
</Window>
private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
{
    new MainWindow().Activate();
}

private void NavigationViewItem_Tapped(object sender, TappedRoutedEventArgs e)
{
    new MainWindow().Activate();
}

Expected behavior

The new window should open and gain focus without affecting the old window's focus or Z-order.

Screenshots

bug.mp4

NuGet package version

WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003

Windows version

Windows 11 (23H2): Build 22631

Additional context

No response

@Scighost Scighost added the bug Something isn't working label Jan 5, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

1 participant