MvvmCross: how to go to something other than ViewModel?

What would I add to my MvxCommand to go to a simple URL? All mobile platforms have a mechanism to ask the OS for an Activity or ViewController that can display the contents of a URL. How do I do this with MvvmCross? One of the ways I know about is to add special things to the presentationBundle and / or parameterBundle file when calling ShowViewModel, which the host can detect to execute the special OpenUrl command. But is this the best way?

+4
source share
1 answer

There is a plugin that allows this - https://github.com/slodge/MvvmCross/tree/v3/Plugins/Cirrious/WebBrowser

If these plugins are loaded, then the view model can use:

public class MyViewModel : MvxViewModel { private readonly IMvxWebBrowserTask _webBrowser; public MyViewModel(IMvxWebBrowserTask webBrowser) { _webBrowser = webBrowse; } public ICommand ShowWebPage { get { return new MvxCommand(() => _webBrowser.ShowWebPage("https://github.com/slodge/mvvmcross"); } } 

You can see how it is used, for example:

If you ever need to create your own plugins, see https://speakerdeck.com/cirrious/plugins-in-mvvmcross

+2
source

Source: https://habr.com/ru/post/1481458/


All Articles