Does Xamarin.Forms have a built-in IoC navigation service? I mean something like Prism, where you could register your routes.
If yes - where is the documentation?
If not - will Xamarin.Forms have a built-in navigation service in near future?
Also - if not - what would be the best MVVM fw for Xamarin.Android, Xamarin.iOS, Xamarin.WinXYZ and Xamarin.Forms? And why?
It seems to me that it comes down to battle between Prism and FreshMVVM - this brings me to my most important questions:
Which of these two is performing better? (Which one is faster?)
Which of these is more likely to lead the way of MVVM frameworks considering mobile development in the future?
No Xamarin Forms does not offer navigation like Prism. They had a goal of making the built in Navigation similar to Prism, but that has since disappeared from their roadmap. There is also no direct IoC concept built directly into Xamarin Forms.
If you are developing native UI's then Prism probably isn't for you as it is purpose built for Xamarin Forms. In that case I might say you should look at MvvmCross. It is battle tested in a lot of classic Xamarin apps.
If however you are developing with Xamarin Forms, then Prism would be the best to use. My opinion may be biased, but it's also the public opinion of many of those on the Xamarin team. Remember Prism was originally started by the Microsoft Patterns and Practices team. While Prism for Xamarin Forms was started after that, the foundation of what Prism is and how it works, helps keep developers developing using proper MVVM patterns.
Question 1: Yes, Xamarin.Forms have a built-in navigation service.
Question 2: Xamarin.Forms navigation
Edit 2 for question 1: No, there is no IoC Navigation built in Xamarin.Forms framework.
But if you want some IoC navigation maybe this a good one: Xamarin Forms - View Model First Navigation avoiding big frameworks like Prism, MVVMLight or MVVMCross. If not this frameworks works well for this purpose.
Related
So I am creating an app in Xamarin forms. I am an experienced .net developer but my Xamarin forms knowledge is still in the early stages.
I want to create a new custom control (Scheduler / Timeline control) that looks like the following picture:
My first idea was to start from controls already existing in Xamarin forms like Grid,...
But now I am thinking, if it is maybe better to start from Android and IOS controls instead?
Is there somebody who has experience in making custom controls like this for Xamarin Forms, and can you point me in the right direction?
What is realistic amount of code share between Xamarin and UWP?
I have app which has following layers:
1. UWP platform specific apis
2. Messaging protocol based on these apis
3. Services
4. ViewModels
5. Xaml Views communicating with INotifyPropertyChanged and ICommand
I understand that obviously 1 (platform specific apis) an 5 (xaml views) cannot be shared. Layers 2 and 3 should be ok. What about ViewModels? I think it should be possible to achieve this using thin layer of viewModel adapter, is this realistic?
Also I am not planning to use xamarin.forms.
The answer depends on your application.
UWP has many specific APIs that as such don't work on Xamarin. They are not necessary related to views only but can be also related to viewmodel code. If your viewmodel is a separate .Net standard project then you can reuse it completely, but as it is not always the case with UWP apps you can probably reuse just most of the code.
The second part comes down to actually using this viewmodel in iOS/macOS project. As you don't want to use XAML (Xamarin.Forms), there is no data binding provided. Basically you have to do whole data binding manually. Some MVVM frameworks may help you in that, but if you ask me they should be called 'helpers', not frameworks.
In Prism for Xamarin.Forms there is an interface INavigationAware. You implement it in the ViewModels (if you want to). There are three methods, OnNavigatedFrom, OnNavigatedTo and OnNavigatingTo. These methods are called by the Prism navigation framework. You can load data, do some logging or cancel the navigation operation.
Now I am using the new Shell Navigation (AppShell) in Xamarin.Forms 4.1 without Prism. Is there something equivalent or similar available with Shell Navigation? Is there an adviced pattern to, for example, load some data from a database when the user navigates to the page or to cancel Navigation Operation?
Edit: I understand Prism does not support Shell Navigation at the moment. What I ask, is to do something similar without Prism.
As was provided above. This question has previously been answered. https://stackoverflow.com/a/56793314/4984832
Xamarin.Forms Shell is not currently supported. It is a planned feature in Prism 7.3 and won't start until sometime after some changes from the Xamarin.Forms team are available in an official build. The issue can be tracked here: https://github.com/PrismLibrary/Prism/issues/1809
Is it possible to mix iOS Storyboards and Xamarin Forms within one application? I have a bunch of views that are easier to be created in Forms, but some which are heavily customized so we would need to create some of them in native code.
I would like to use Storyboards to create the native parts, but can't seem to find a way to navigate from a Forms page to a Storyboard and vice versa.
I don't mind doing it from code, just need to know the direction to look into and if it's even possible.
You can create native views using the concept of Custom Renderers (see links below). The idea is that you create a Xamarin Forms Control that's shared between all platforms and which old common properties (like colors, general data etc), and do the native rendering on the iOS/Android/WP projects.
So, for your storyboard, you can create it usign Xamarin.iOS, and render using a Custom Renderer. The link posted by #GSerg in the comments have some information and examples, but you can take a closer look at the oficial documentation as well:
Introduction to Custom Renderers
Customizing Controls on Each Platform
Customizing Control Rendering in Xamarin.Forms (video)
Also, for more real world examples you can take a look at the Xamarin Forms XLabs project.
Thanks to Rafael Steil's answer. I looked at the links and a few more samples.
Notably:
Custom Renderer Map
Using Xamarin Forms alongside Storyboard
And I created a sample project to show the back-and-forth navigation between Xamarin Forms and pages created in Storyboards. You can find it over here:
Xamarin Forms Mixed with Native
Hello All, Can i code one UI for all platforms using Mvvm Cross framework in Xamarin?
Like i code for a generic UI which can generated for different platforms Android,IOS,Windows.
I saw Xamarin Forms giving some thing like this , but what about MVVMCross.
So if i conclude in simple sencario , since xamarin forms uses Mvvm so its better to use xamarin forms instead of mvvmcross for one single Ui
No, Mvvmcross doesn't provide UI automagically. View is platform specific while models and viewmodels are platform independent.
With Forms all three are platform independent. To make this work Forms added another layer, called Renderer (which is platform specific). Out of the box there is a bunch of renderers, then there is 3rd party community (specially Forms Labs) and finally, you can make your own renderers or extend existing ones.