The ArticleView is responsible for rendering the article for us. To keep things simple (and also illustrate that you don't always need a ViewModel), we will not define a ViewModel for this class, but rather define the BindingContext as an instance of the UrlWebViewSource class.
Add the following code to the ArticleView.xaml.cs file:
- In the News project, expand the Views folder and open the ArticleView.xaml.cs file.
- Add the following code marked in bold to the file:
using System.Web;
using Xamarin.Forms;
namespace News.Views
{
[QueryProperty("Url", "url")]
public partial class ArticleView : ContentPage
{
public string Url
{
set
{
BindingContext = new UrlWebViewSource
{
Url = HttpUtility.UrlDecode(value)
};
}
}
public ArticleView()
{
InitializeComponent();
}
...