My app has a WebView for displaying some contact information. It has a link to a website that I want to load externally using Device.OpenUri()
. I\'m using FreshMvvm
Having revisited this recently for another project I stumbled across the answer. The updated XAML is:
The code in the ViewModel, that matches the tapped url against a list of valid options before opening the link in the device's browser, is:
public Command NavigatingCommand
{
get
{
return navigatingCommand ?? (navigatingCommand = new Command(
(param) =>
{
if (param != null && -1 < Array.IndexOf(_uris, param.Url))
{
Device.OpenUri(new Uri(param.Url));
param.Cancel = true;
}
},
(param) => true
));
}
}