Following simplified XAML works fine in Xamarin.Forms and Maui:
<ScrollView HorizontalScrollBarVisibility="Never">
<StackLayout>
<WebView x:Name="WebView" VerticalOptions="FillAndExpand">
<WebView.Source>
<HtmlWebViewSource Html="{Binding html}"/>
</WebView.Source>
</WebView >
</StackLayout>
</ScrollView>
Now in Maui because "FillAndExpand" and expand is obsolete and might not work in the future I tried setting it to "Fill", but then WebView doesn't get resized.
So I tried replacing StackLayout with VerticalStackLayout, but still doesn't expand:
<ScrollView HorizontalScrollBarVisibility="Never">
<VerticalStackLayout>
<WebView x:Name="WebView" VerticalOptions="Fill">
<WebView.Source>
<HtmlWebViewSource Html="{Binding html}"/>
</WebView.Source>
</WebView >
</VerticalStackLayout>
</ScrollView>
So my question is - why does obsolete property works fine, but not the new one? And more importantly, how can I fix this issue?
You can use Grid
instead of VerticalStackLayout
which will expand automatically:
<ScrollView HorizontalScrollBarVisibility="Never">
<Grid>
<WebView x:Name="WebView">
<WebView.Source>
<HtmlWebViewSource Html="{Binding html}"/>
</WebView.Source>
</WebView >
</Grid>
</ScrollView>