How can I add HTML to a Stacklayout inside a Scrollview in Xamarin forms?

Viewed 3906

In my application I have a Contentpage with a Scrollview in it. The Scrollview in turn contains a StackLayout with lots of labels with text. In the middle of this I want to insert some static HTML.

I have tried adding a Webview with static HTML as a child to the StackLayout but the Webview is not visible then (Probably the height gets calculated to zero)

Does anyone know how to fix this? Or is there some other way to add HTML in the between all the labels?

StackLayout mainLayout = new StackLayout ();

// Adding many labels of different sizes
mainLayout.Children.Add (new Label {Text = "Label text"});

mainLayout.Children.Add ( new WebView {
            Source = new HtmlWebViewSource {
                Html = "<html><body>Hello</body></html>"
            }
});

// Adding many more labels of different sizes
mainLayout.Children.Add (new Label {Text = "Even more Label text"});

Content = new ScrollView {
            Content = mainLayout
        };
2 Answers
Related