The Xamarin Show 10: Prism for Xamarin.Forms with Brian Lagunas

Download this episode

Download Video

Description

This week, James is joined by friend of the show Brian Lagunas, XAML Product Manager for Infragistics, who introduces us to Prism for Xamarin.Forms. Brian walks us through exactly what Prism is and how developers can get started and leverage Prism in their Xamarin.Forms applications. He shows us all of the features of Prism including template packs, navigation service, deep linking, commands, and other features of the library.

Segments:

  • [06:30] What is in Prism for Xamarin.Forms?
  • [09:00] Where to Get Started with Prism
  • [12:00] Creating First Prism Application
  • [35:00] Passing Parameters
  • [43:30] Full Sample Walkthrough Deep Links

Show Links:

Useful Links:

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Mike

      Brian is awesome.
      The amount of work this guy is doing is unbelievable. Hats off to him!
      If the Xamarin Forms team would do just 20% of this one guy's work, Xamarin Forms would be much better.

    • User profile image
      dimpyd

      Such a nice demo. I wish I had known about this before I started building my first app using XForms. It would have made my life so much easier. Lot of these features can pretty much be part of the XForms framework tbh. Navigating in XForms while maintaining MVVM sanity is not really an easy thing to do. I learned it the hard way, no regrets!

    • User profile image
      alex

      Personally, I would do it like this

      register
      ---
      navigation.Register<MainPage>().With<int,String>("id", "name");
      or navigation.Register<MainPage>().With<int,String>();

      navigate
      --
      navigation.Navigate<MainPage>().With(11,"alex");


      MainPageParams
      {
      public int ID;
      public string Name;
      }

      navigation.Register<MainPage>().With<MainPageParams>();
      navigation.Navigate<MainPage>().With(new MainPageParam{ID = 11,Name = "alex"});

      (if MainPageParams have defaut ctr, with some magic this could work too, it could create one param object on the fly)
      navigation.Navigate<MainPage>().With(11,"alex"});

      this could easily support "text" navigation too

      ---
      note that i fixed the naming because i find it useless and ugly to add "Service" or "Async"
      also i register the page on the navigation service not in the container.

    • User profile image
      alex

      also i would prefer

      App.TestMode = true; (set when testing)

      App.Register<>().With<>().Default()
      App.Navigate<>()

      when TestMode is true pass Default values and bypass visual navigation (using a stub or something)

      this way you dont need any Application NavigationService reference stored anywhere in your viewmodels.

      you could have a navigation object in a viewmodel for internal navigation tho..

      to do chaining you could return the actual viewmodel navigator if that viewmodel support IHaveNavigator.

      App.Navigate<>().With<>().Navigate<>().With<>().
      ---
      Dependency injection isnt the only way to make your app testable, since you are doing the APP Framework itself, this is one way i would prefer in an fluent navigation App framework.

    • User profile image
      Brian Lagunas

      @alex: Thanks for your feedback.  Unfortunately, there are a number of issues with trying to support a fluent API like you are suggesting.  For example; your desire to navigate to a concrete Page type breaks the MVVM pattern.  So, I would never consider doing that.  Even if you had the ability to navigate to a Page concrete type, you could not do deep linking with this API.  The process of building up a complex navigation stack using this API would not be possible.  In the end, this is just an coding style preference.  You do not gain anything substantial from using it.  Essentially, you are going through all this trouble to avoid using a navigation URI, which goes against the entire reason for using a URI based schema.

    • User profile image
      fm2000

      I started using Prism in WPF and it's been a pleasure to use it in Xamarin Forms.  Thanks Brian for all your work. 

      Hope Brian gets invited again to show the other features.

    • User profile image
      DigiPug

      Awesome show... Thanks so much, James & Brian! As a fairly new Xamarin.Forms developer, my biggest request is for more & more sample code, and to bring Brian back on the show to discuss Prism in greater detail and in more complex situations. Maybe even a show on common "gotchas" that Prism n00bs tend to run into.

       

      Thanks again to both of you for all your great work!

    • User profile image
      cakmak

      thank you Brian Lagunas and James Montemagno very useful tutorial

    • User profile image
      RichL

      Fantastic demonstration; I currently have my navigation in the view code behind based on viewmodel actions which I hate. Two questions:
      1) how difficult is this to retrospectively plumb in to a xam forms project? are there steps as to what I need to remove/add?
      2) are you aware of any issues using 3rd party components which utilise navigation. I use an ScandIt plugin that does barcode imaging and currently just call their ScanAsync method which handles navigation to the camera overlay and responds with a Task result, would Prism interfere/cause issue with this?

    Add Your 2 Cents