Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Example 2 an App that uses Restful Web Services and also the MvvM Web Browser Plugin

PeterBurke edited this page Jul 30, 2015 · 3 revisions

Almost every App one can imagine will need to access a Restful Web Service or display a web page.

This example is a simple App where you search using a web service for information about a Movie, get a list of results that you can open and then Navigate to a page of details. From there you can click a link that opens a web page using the standard browser.

When you enter the name of a Movie and click search, it sends this off to the Restful web service at "api.themoviedb.org/3/" and gets back a json packet that it decodes using Newtonsoft.Json (Json.net) and presents as a list.

Clicking an item navigates to the Detailed page where the details from the json are displayed. From here we can click a link that brings up the native web browser using the MvvmCross Web Browser plugin and displays more information.

This sample was originally written by one of us Tomasz Cielecki seven months ago. Tomasz is the original founder of MvvmCross-Forms.

The example is available both as C# and XAML.

It demonstrates just how easy it is to use an MvvmCross plugin. The steps are as follows:

  • In visual Studio select the PCL project containing the Pages and ViewModels and then from the Tools menu, manage NuGet packages. Search for the MvvmCross web browser control and add it to the project.

  • Also add a new source code file to the project WebBrowserPluginBootstrap.cs

using Cirrious.CrossCore.Plugins;

namespace Example.Bootstrap
{
    public class WebBrowserPluginBootstrap
        : MvxPluginBootstrapAction<Cirrious.MvvmCross.Plugins.WebBrowser.PluginLoader>
    {
    }
}
  • Use the Web Browser in a button Command method in the ViewModel

        public ICommand ShowOnImdbCommand
        {
            get
            {
                return new MvxCommand(() => 
                    Mvx.Resolve<IMvxWebBrowserTask>().ShowWebPage(ImdbUrl));
            }
        }