locked
PRISM Navigation with Xamarin.Forms application for UWP produces artifcats. RRS feed

  • Question

  • User394095 posted

    My Xamarin.Forms application is a MasterDetailPage application which uses PRISM framework. I have listed below the series of actions I perform to produce the artifact.

    1. Hamburger Menu Page(MasterDetailPage): NavigationService.NavigateAsync("NavigationPage/LandingPage");
    2. Landing Page is a tabbed page: NavigationService.NavigateAsync("CreatePage");
    3. CreatePage is a content page with its NavigationBar disabled: NavigationPage.SetHasNavigationBar(this, false); NavigationService.NavigateAsync("SelectPage");
    4. SelectPage is a content page with its NavigationBar disabled as well: NavigationPage.SetHasNavigationBar(this, false); You can notice a grayish bar on the top. Which I believe is the UWP AppBar, maybe?
    5. Navigating back to CreatePage: NavigationService.GobackAsync(); NavigationPage.SetHasNavigationBar(this, false); The same grayish bar can be observed here as well along with the HamburgerMenu icon.

    It will be really helpful if anyone can explain what is going on? and how to have this fixed? Meaning, I don't want that horrible gray bar appearing.

    Thursday, May 21, 2020 5:52 AM

Answers

  • User371028 posted

    I found a global solution. I went to the Xamarin Repo and copied the whole MasterDetailControlStyle.cs into my UWP app and added it as a Resource to the UWP App.xaml. In the style I set Visibility="Collapse" to the element with x:Name="TopCommandBar".

    Are we looking at a Xamarin bug here with this that I should report? Not sure why SetHasNavigationBar(this, false) for this shouldn't work.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, June 7, 2020 5:42 PM

All replies

  • User371028 posted

    We are having problems with this as well. I'm looking into making a custom renderer and seeing what I can change from there. Any luck on solving this issue?

    Thursday, June 4, 2020 6:05 PM
  • User394095 posted

    @mnxamdev said: We are having problems with this as well. I'm looking into making a custom renderer and seeing what I can change from there. Any luck on solving this issue?

    Hey @mnxamdev , I am using NavigationPage.TitleView in xaml to put my own Label as title and a button to act as a toolbar icon. This also makes sure that the navigation bar for these pages need to be disabled, which I feel is causing this artifact.

    Doing so, I have avoided the weird grey bar and in certain situations where the above mentioned 'hack' is not feasible, I am performing an absolute URI based navigation to the particular page I want to land in like this:

    NavigationService.NavigateAsync("myApp:///HamburgerMenuPage/NavigationPage/LandingPage/DesiredPage");

    But I can't vouch for how well this functionality has been handled for UWP by PRISM, although it being a Xamarin.Forms project :neutral:

    I haven't been successful in understanding how NavigationBar is handled by Xamarin.Forms for UWP.

    If you've just started to develop your UWP application with Xamarin.Forms and Prism, go through this, and decide if you want to go down that road. Our app is already in production and I don't have a choice. :neutral:

    Friday, June 5, 2020 7:25 AM
  • User76049 posted

    It's nothing to do with Prism, this the default platform behavior for UWP in Xamarin ...which is not good when it comes to styling. The Prism team decided to do down the Uno route with Prism. For a future path it totally makes sense and Xamarin support for UWP is sketchy, previous app I worked on had UWP support and the majority of our issues were UWP.

    https://github.com/unoplatform/Uno.Prism

    The issues are more the fault of UWP underneath not Forms speaking from experience of having to try and customize UWP UX behavior although the whole Forms UWP toolbar is a bit horrible and TitleView doesn't really do now what people want.

    Friday, June 5, 2020 8:30 AM
  • User394095 posted

    @NMackay , Sounds like Xamarin.Forms is not a very viable option for UWP development. Maybe, .NET MAUI framework will make things better.

    Sunday, June 7, 2020 7:37 AM
  • User371028 posted

    I found a global solution. I went to the Xamarin Repo and copied the whole MasterDetailControlStyle.cs into my UWP app and added it as a Resource to the UWP App.xaml. In the style I set Visibility="Collapse" to the element with x:Name="TopCommandBar".

    Are we looking at a Xamarin bug here with this that I should report? Not sure why SetHasNavigationBar(this, false) for this shouldn't work.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Sunday, June 7, 2020 5:42 PM
  • User76049 posted

    @mnxamdev

    Yeah, had to do workarounds like that before, to me, that's a bug.

    Sunday, June 7, 2020 5:46 PM
  • User394095 posted

    @mnxamdev I am marking your response as the current answer. Also, if you have raised a bug in the xamarin repo, can you post the link here?

    Wednesday, June 10, 2020 4:23 AM