NavigationView throws threading error when used in new window
See original GitHub issueDescribe 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:
- Create UWP app
- Add NavigationView to main page
- Create new page with a NavigationView
- Add code to launch a new window, and navigate to that frame. (See example below)
- Launch the app and run code to open the new window
- 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:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ranjeshj TestApp.zip
I can’t repro the issue anymore either. Since the issue seems to be solved, closing. Thanks for the fix! 😄