Xamarin.Forms default navigation bar font - xamarin

In Xamarin.Forms I have created a custom Navigation bar using a StackLayout and Labels for one of my pages. The other pages however are using the default navigation bar. I've tried to make the titles of the custom and default navigation bars look exactly the same but can't quite get it to match.
Is there a way to find out the font size and family of the default navigation bar in Xamarin.Forms?

Yes, there is! Xamarin.Forms is fully open-source, so you can inspect anything the code is doing on GitHub. The magic most likely happens inside the NavigationPage renderers, so check out Xamarin.Forms.Platform.[Target Platform]/Renderers/NavigationPageRenderer.cs.
But in your case this might be overkill, and you might be able to get the information you are interested in using the Xamarin Inspector while your app is running in debug mode.

Related

Difference between Prism Dialogs vs Popup

I am implementing Prism in a new Xamarin Forms App. I have been using Rg.Plugins.Popup in the app before converting to Prism.
What are the limitation on the Prism Dialogs vs Prism.Plugin.Popups?
What are some examples when you would use one over the other?
Thank you!
Rg.Plugins.Popup is a popular plugin for Xamarin.Forms which accesses the native functionality to provide a "Modal Popup" which traditionally has not been achievable with Xamarin.Forms.
Dialogs in Prism 7.2
If you're using Prism 7.2 you'll find that the DialogService locates the currently displayed page and then "reparent's the content". Or in other words it takes the content of the active Content Page and places it as the root child of an AbsoluteLayout, placing a mask layer and finally your dialog on top. As a result of this approach you'll notice that any navigation bars for instance on the NavigationPage or TabbedPage, or a MasterDetailPage's menu will remain accessible to the user.
While in some regard both the PopupPage and Dialog may look very similar as you can probably tell there is some significant divergence there.
Dialogs in Prism 8
If you're using Prism 8.0 you'll see that we have updated to the latest Xamarin.Forms and as a result we are able to take advantage of a new feature in Xamarin.Forms which allows you to present a Modal Page with a Transparent background. This in effect allows you to replicate the effect of a PopupPage with either some benefits or drawbacks depending on how you look at it.
With Rg.Plugins.Popups you have the ability to push a PopupPage on top of whatever page is currently displayed from anywhere in the app
With Xamarin.Forms page's that have been pushed Modally they are part of your active Navigation Stack
Using the a traditional page with a transparent background and Modal Navigation you in effect have replicated the appearance of what you get with a PopupPage
Limitations
Prism.Plugin.Popups has the benefit of being integrated into the Navigation Service. As such you can inject the Navigation Service into the ViewModel of a PopupPage, and the PopupPage will be dismissed when you navigate away from it to another non PopupPage.
Dialogs are not part of the Navigation Stack tracked by Prism's Navigation Service. Navigation in Xamarin.Forms is dependent on navigating FROM a specific page. Since Prism's NavigationService doesn't know about the Dialog you will need to dismiss the dialog before navigating.
Other Key Differences
Besides what I've mentioned so far the only real difference is that Rg.Plugins.Popup gives you some added animations which honestly I've seen very few people using.

Tabview vs. GridLayout vs. DockLayout

I checked almost every demo application from the website, but nobody use tabview, only Gridlayout or docklayout for "tabbing" purposes. What is the benefit of the Gridlayout instead of tabview? Apart from the customize the background.
My point is to have a native tab look and feel on every page.
If I have page 1, page 2, page 3, all the page components should have the same tabview/GridLayout part, or I can move out the tabview section to an individual global component?
Apologize for the basic question.
Thanks!
If you are looking for pure native look and feel, you would go with a TabView. Another advantage with TabView is lazy loading, it loads the page only when required.
You may go with GridLayout when you want to keep the TabView look similar on both iOS and Android. iOS by default uses Tabs at bottom and Androids places them at top. iOS would give you a More tab when the number of tab exceeds the available space, on Android it will be scrollable. These are by native, so if you want a customised common look and feel, then you could use GridLayout. Or still you could use the TabView and replace the TabBar with your own custom view, which is a bit complicated.
If you want the tabs on every page, then you should probably have a Frame inside each tab and load your pages there. So the TabBar remains same on every page. The same could be achieved with GridLayout, it's all about choices. I personally like sticking with the native look and feel of platform.

TabbedPage bar glitch

When I open TabbedPage from another TabbedPage in Xamarin.Forms for iOS the right part of bottom bar has that strange glitch/blink. Is there any solution to fix it?
There might be a need to reconsider UX in the app you are working on. Nested tabs are not intuitive and very confusing, beside the technical issues you can run into, here is a summary of notes from the official Xamarin.Forms docs:
It's recommended that a TabbedPage should be populated with
NavigationPage and ContentPageinstances only. This will help to ensure
a consistent user experience across all platforms.
The TabbedPage does not support UI virtualization. Therefore,
performance may be affected if the TabbedPage contains too many child
elements.
While it's acceptable to place a NavigationPage into a TabbedPage,
it's not recommended to place a TabbedPage into a NavigationPage. This
is because, on iOS, a UITabBarController always acts as a wrapper for
the UINavigationController. For more information, see Combined View
Controller Interfaces in the iOS Developer Library.

Xamarin.Forms styling

I develop Xamarin.Forms app (latest version of Xamarin), I'm targeting only Android. I use TabbedPage which displays bar on the top of the screen. I want to make my custom visual item that will look like the TabbedPage bar. Where can I find out font size, font type, background color, margins etc so I can make my custom visual item that will look like TabbedPage bar?
As you said that you want to create tabbed page I think you should use Xamarin.forms controls (https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/tabbed-page/). But if you want to create custom tabbed then you have to use custom renderer for top navigation bar.

Custom Navigation with Xamarin.Forms

I’m working on an application for Android and iOS, which requires a certain flexibility for one or two views. That’s why we created & implemented a service that translated a basic list of objects into a user interface for both iOS & Android. But now that Xamarin.Forms is released, we decided to replace our service by the one Xamarin provides. I did succeed in creating the views with Xamarin.Forms, resulting in better looking & smoother running pages. But my problem lies in the navigation of it. Here is a little drawing on what I would like to achieve:
I would like my app to start an activity that starts with a custom fragment. After clicking a button on this fragment, I would like the page I created with the Xamarin.Forms api to be added to my current navigation stack! Once the user is finished with the Xamarin.Forms page, it navigates to a second custom fragment, all that without breaking the navigation cycle. Does anybody have an idea on how I can achieve this?
For the iOS developpers: replace Activity with NavigationController & Fragment with ViewController
Take a look at CarouselPage for Xamarin.Forms' own approach. It doesn't look like that's what you need but you can also look at its source code and maybe make a custom renderer yourself.
You may also want to take a look at MVVM
As for the easier/hackier way you'd want to make a button on each page and when the button is tapped execute Navigation.PushModalAsync(nextPage) - there won't be a "< Back" button any more, you may need to implement that yourself if you need it.
If by your meaning of 'current navigation stack' is for using the native Navigation of each platform, then remember that you don't have to use Xamarin.Forms' Navigation Model and functions such like PushAsync.
If you prefer to do Navigation with code specific to each platform then you can do this the same as normal. Just create your stub pages in each platform specific project and set the Xamarin.Forms content for each page from the shared project.
From each platform specific stub page (Activity / UIView / PhoneApplicationPage) you could then execute an Action<> call setting on the shared Xamarin.Forms page to help with the navigation, or alternatively, hook into a custom-event that is raised from the Xamarin.Forms** page back to the platform specific stub page to allow you to do navigation from there.
Like Sten mentioned there won't be any 'Back' button so you will most likely have to do that yourself.

Resources