Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

ListView DataTemplate with WebView showing blank

$
0
0

I'm trying to set the DataTemplate of a ListView to a WebView. Actually a ViewCell containing a WebView, and bind the HTML of the web view to data property. However, it shows nothing. The ListView is blank. Anybody help? Below is my code.

    var dtPDL = new DataTemplate(typeof(HomeListWebViewCell));
    var lvPDL = new ListView
            {
                ItemsSource = ViewModel.TestPDLList(),
        DataTemplate = dtPDL
            };

    public class HomeListWebViewCell : ViewCell 
        {
            public HomeListWebViewCell()
            {
                var wv = new WebView();
                var wvs = new HtmlWebViewSource();
                wvs.SetBinding(HtmlWebViewSource.HtmlProperty, "MainText");
                wv.Source = wvs;

                this.View = wv;
            }
        }

Viewing all articles
Browse latest Browse all 58056

Trending Articles