question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NavigationView throws threading error when used in new window

See original GitHub issue

Describe the bug

As of WinUi 2.5, NavigationView throws the following error when used in a separate UWP window: The application called an interface that was marshalled for a different thread.

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Create UWP app
  2. Add NavigationView to main page
  3. Create new page with a NavigationView
  4. Add code to launch a new window, and navigate to that frame. (See example below)
  5. Launch the app and run code to open the new window
  6. See error

Window launch code example:

CoreApplicationView newWindow = CoreApplication.CreateNewView();
ApplicationView newView = null;
await newWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
  Frame frame = new Frame();
  frame.Navigate(typeof(NewPage), null, new SuppressNavigationTransitionInfo());
  Window.Current.Content = frame;
  Window.Current.Activate();

  newView = ApplicationView.GetForCurrentView();
  newWindow.TitleBar.ExtendViewIntoTitleBar = true;
});
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newView.Id);

Expected behavior

The navigation view should work in a separate window.

Screenshots

Version Info

NuGet package version: [Microsoft.UI.Xaml 2.5.0]

Windows app type:

UWP Win32
Yes ?
Windows 10 version Saw the problem?
Insider Build (21277.1000) yes
May 2020 Update (19041) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox ?
Surface Hub ?
IoT ?

Additional context

This bug was discovered here

Edit: fixed package version

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tsvietOKcommented, Jan 6, 2021
0reactions
winston-decommented, Jun 25, 2021

I can’t repro the issue anymore either. Since the issue seems to be solved, closing. Thanks for the fix! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

NavigationView gives an exception when it's the only thing ...
I'm using the new Project Reunion 0.5/WinUI3 Preview 5. And after my upgrade from Preview 4, I started to get this error: Exception...
Read more >
SwiftUI - NavigationLink inside Na…
When I tap the link, it directs to the new view just fine. However, when I tapthe back button, the app throws the...
Read more >
SwiftUI - NavigationLink inside Na…
SwiftUI - NavigationLink inside NavigationBarItems, returns error on navigating from detail back to master view.
Read more >
Error in Navigation View Items Selection Changed C# ...
I'm new to develop UWP apps in Windows. I want to redirect frames when user clicks on particular NavigationViewItem in my app. 178342-screenshot ......
Read more >
Navigating Between Pages | Universal Windows Apps with ...
When you navigate to a Page by calling Navigate, you get a new instance of it, regardless of NavigationCacheMode. No special relationship exists ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found