Xamarin.forms: [Bug] Shell Navigation.PushAsync ignored on UWP platform

Created on 14 Nov 2019  Â·  46Comments  Â·  Source: xamarin/Xamarin.Forms

Description
Using the solution created by VS2019 for shell and then adding a UWP project to it does not work correctly, the call to Navigation.PushAsync to bring up the detail form is ignored but the same project works correctly with Android and iOS

Steps to Reproduce
Create a new solution with VS2019, select shell project for iOS and Android.
Add in the UWP project, update the UWP code for Xamarin as documented.
https://stackoverflow.com/questions/41192203/how-can-i-add-a-uwp-target-to-an-existing-xamarin-forms-project

Upgrade the Nuget for the project to use the 4.3 release of Xamarin.Forms

Add the line global::Xamarin.Forms.Forms.SetFlags("Shell_UWP_Experimental"); prior to calling Xamarin.Forms.Init

Compile and run in UWP mode

When the app runs select the "First item", this should then display a new page with the details of the first item. On UWP it does not, it stays on the same page. it seems that the line

await Navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(item)));

is being ignored in UWP

Expected Behavior

I expected that when I selected the "First item" it would bring up the details page for this first item.

shell 4 high impact UWP tablet bug

Most helpful comment

the problem is in Xamarin.Forms.Platform.UAP\Shell\ShellItemRenderer.cs. The method OnNavigationRequested() calls SwitchSection() and passes to it the page to be navigated to, but the SwitchSection method ignores that parameter and instead navigates to the current Shell section.

Good find @JogyBlack . I have a PR in the works with push working, now I just need to make some of the other things around it work as well (Backbutton, switching tabs/flyout doesn't kill stack, other things I find along this journey)

Thank you for diving in!!!

All 46 comments

Guys, Curious if this is going to be fixed in the near future since it a basic need in the application, without the ability to navigate its hard to test more of the basic system

I notice it has a tag of e/5 but my other bug has an e/4. this bug is way more important than the other one by far

8498_Repro.zip
Looks like the repro does not include a UWP project, I have updated it to include the UWP project

Not sure why this got closed, sorry

I notice it has a tag of e/5 but my other bug has an e/4. this bug is way more important than the other one by far

@curtisconner The e tags are a very, very rough estimate of the effort required to fix the problem; it has nothing to do with the importance of the issue.

Hello I am newbie to Xamarin.Forms. I think the shell is a great idea.
That's why I wanted to test it with UWP.
I checked out the following:
https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/Xaminals
and add UWP support, of course with experimental flag.
I still have to copy the pictures into UWP Project and then it looked like it works.
But I can’t navigate to a detail page, await Shell.Current.GoToAsync… does not seem to work under UWP.
In search of a solution, I ended up here. Now I do not know if my problem is the same. I am still too newbie.
Could one possibly tell me if I'm at the right bug?
Thanks!

Yes that’s the bug. In fact all navigation is broke other than shell or tab navigation at this point.

Sent from my iPad

On Dec 7, 2019, at 7:35 PM, DiagProf notifications@github.com wrote:


Hello I am newbie to Xamarin.Forms. I think the shell is a great idea.
That's why I wanted to test it with UWP.
I checked out the following:
https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/Xaminals
and add UWP support, of course with experimental flag.
I still have to copy the pictures into UWP Project and then it looked like it works.
But I can’t navigate to a detail page, await Shell.Current.GoToAsync… does not seem to work under UWP.
In search of a solution, I ended up here. Now I do not know if my problem is the same. I am still too newbie.
Could one possibly tell me if I'm at the right bug?
Thanks!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

Guys, I could use your help. I have modified the source from the 4.3 branch to get the basic navigation to work, it will now load a new page and show the back arrow. But when I try to implement the back button I get failure. Its seems that there is a need to create a new page not just use the frame.goback method. Not sure what's going on here.

My source is at https://github.com/curtisconner/Xamarin.Forms-UWP-Shell-Navigation and the changes can be found in the region commented under Navigation. all changes are in the Shell directory.

Any help would be great

OK I guess no one is using this feature so I might as well just ignore it and use another platform. thanks

I waiting two month for this fix :)

So am I ;)

Yes it is very very important. You do a great job (really) but I think you underestimate UWP (tablet and especially desktop). With the arrival of Shells, UWP had a bad cold and we had to postpone a major version (we didn't think it would take as long to finish the job). So thank you for healing the UWP. Have a nice year.

I have the same problem. Navigation.PushAsync() does not work for the UWP project. Using Shell and updated to latest Xamarin Forms 4.4.0.991640

It's also extremely important for our Magic Gradients library. We have Playground project which is showcase/gallery app. It's using shell as it was promoted as a preferred way of structuring your app and we really like this approach. We want to show that we are also supporting UWP, full screen gradients on desktop are mind blowing. It was a slap in the face that basic functionality like navigation just doesn't work. I know UWP is not your primary platform but if you officially support it and it's not community driven, it would be nice if such basic features just works :)

Version 4.5.0.356 and no progress on this. If we have to wait this long to get basic UWP support for something as fundamental as Shell navigation in Xamarin.Forms, the future does not look good for UWP app development with XF. Do we need to re-think our strategy if we have a business need - and a desire - to support and develop shared apps across iOS, Android, _AND_ Windows?

I downloaded Xamarin.Forms sources from GitHub and tested in the Xamarin.Forms.ControlGallery.WindowsUniversal project, which has a Store Shell section. There is a "Navigate to 'demo' route" button and it does not work as well. I debugged it a little, and it seem the problem is in Xamarin.Forms.Platform.UAP\Shell\ShellItemRenderer.cs. The method OnNavigationRequested() calls SwitchSection() and passes to it the page to be navigated to, but the SwitchSection method ignores that parameter and instead navigates to the current Shell section.

In short, looks like the functionality to navigate to a page that is not listed in the AppShell collection is not implemented at all in the UWP Shell Renderer.

There is an ugly workaround, which is for any page that you want to navigate, add it in the Shell collection, perhaps in a tab, set it's title to empty string, set IsEnabled to false, set it's Route property to custom string, and then use Shell.Current.GoToAsync() to navigate to that route. If you need to pass parameters to the page, use the method described here: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/navigation#pass-data

@JogyBlack If you found the issue maybe you could create PR with the fix?

@JogyBlack If you found the issue maybe you could create PR with the fix?

I am still not familiar enough with Xamarin.Forms source to be able to determine what should be the correct fix. I tried one simple code change, but it did not work.
I will continue digging.

the problem is in Xamarin.Forms.Platform.UAP\Shell\ShellItemRenderer.cs. The method OnNavigationRequested() calls SwitchSection() and passes to it the page to be navigated to, but the SwitchSection method ignores that parameter and instead navigates to the current Shell section.

Good find @JogyBlack . I have a PR in the works with push working, now I just need to make some of the other things around it work as well (Backbutton, switching tabs/flyout doesn't kill stack, other things I find along this journey)

Thank you for diving in!!!

@PureWeen Thanks for the update, this is great news. I can try to help with testing the behavior once the changes are in.

@jamesmontemagno Magic Gradients would be even more awesome if this would be fixed :) https://github.com/xamarin/Xamarin.Forms/issues/9407

@PureWeen good luck with the fix, I also need this as soon as possible.

Effectively, good luck. I really appreciate your effort. Thank very much.

Please fix this ASAP @samhouts any ETA on a fix?

How can basic functionality like navigation be allowed to stay broken since November?

Yeah this is kind of the frustrating thing about xamarin.forms now. Its a good platform for the ios and android phone people, so so with the ios tablet and now its becoming a second class citizen for uwp. And if your wpf... well good luck. We have a huge investment in xamarin.forms now and it looks like we may have wasted our time. We need full support for UWP, sorry our application has to support those nasty old computers not only those cool phones.

Curious, is anyone at all working on this issue or should i dig back into this?

Sorry to vent but this has been an real eye opener on how xamarin.forms feels about uwp

@jsuarezruiz :)

Hi! I hope everyone is doing well. @PureWeen have you had time to check what it is and how long (approximately) it will take to fix it? I know that @dotMorten has also done a great job of implementing shell in UWP. Does he have any idea of ​​a solution? If the answer to all my questions is no, could you set a date (approximately, by June 2020, this spring, etc.) to just give us an idea? Thanks again for your work. Have a nice week.

I am also waiting on this fix.

7 months without working navigation? Is this how the team treats critical bugs?

Beyond a joke, it's so much faster to debug in UWP, then test on Droid\iOS. Except... you can't.

@hartez @samhouts Can we get some answers here? Leaving UWP apps crippled for 7 months seems like a massive oversight.

We're on it, friends. Sorry about the delay.

Thank very much. My team and I really appreciate. Have a nice weekend.

@hartez @samhouts Can we get some answers here? Leaving UWP apps crippled for 7 months seems like a massive oversight.

Particularly when you factor in project re-union which is finally the right direction and one of the stacks to be merged is ignored.

Do you have an ETA?

I am using a UWP project and Xamarin.Forms (4.7.0.968). Navigation.PushAsync works first time but then freezes after that? Is this the same issue?

No ETA as of yet

The thing about this issue is that it's not really a bug. None of the navigation for Shell UWP is really built, so it's not just fixing an if statement. It's wiring up the back button, fixing the title, filling in all the other nav apis, switching flyout items maintains stack, etc..

I'm close to having the features of "push" done as the first functional step and then I'll create additional issues for the other parts that people can follow.

So are you saying that you cannot use Xamarin.Forms with a UWP project??

No, he's saying that this particular feature of Forms is not yet fully implemented for UWP. Using Forms with UWP will work fine if you are not using this particular feature.

So if I understand correctly: you can use Xamarin Forms with UWP, the new feature, Shell is not yet fully implemented for UWP. So there are some options:

  1. do not use Shell until it works with UWP, use plain old Xamarin Forms which should work just fine
  2. wait until Shell is fully implemented for Xamarin Forms, then use it
  3. implement it yourself, be a hero and safe the day

Repeatedly asking are we there yet will not speed up the process, just make this ticket longer.

Thanks team! Unfortunately, a lot changes in 8 months, and we have moved on to navigation routes. I.e. Shell.Current.GoToAsync, which doesn't work in UWP. Is there a bug open for this @samhouts @hartez? I can't find one.

@g4mb10r No, there isn't. Would you mind opening one? Thanks!!

closed by #11410

After update to "Xamarin.Forms" Version="4.8.0.1269"

Getting other exception on
ArgumentException: An item with the same key has already been added. Key: background

line 71:
rootFrame.Navigate(typeof(MainPage), e.Arguments);
In
https://github.com/filipoff2/MagicGradients/blob/issues/Add-UWP-Playground-Project-45/Playground/Playground.UWP/App.xaml.cs

Result:
On 4.8 App is crashing on start
On 4.5 navigation was not done.

@samhouts new issue?

@filipoff2 yea if you can log a new issue so that we make sure it's not missed that would be helpful!!

Was this page helpful?
0 / 5 - 0 ratings