locked
Webview dimensions to fit all resolutions

    Question

  • Hello

    I have a webview that is displayed inside 2nd column of grid with width definition 100* and height definition 95*

    I do currently set webview width to 860 and height to 650. I did run my app on simulator to check behavior for different available resolutions. It is not show properly in all , for example for 23'' and 27'' it looks very small.

    Is there a way to make my webview show content relatively to user device resolution from xaml? Or  do I have to check from code behind the user's device resolution and change webview width and height accordingly each time ?

    Thursday, November 13, 2014 7:33 AM

Answers

  • Don't explicitly set the height. Let it stretch to fill the whole cell.

    This will be the default behavour if you don't explicitly set the height:

        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="100"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <WebView Source="http://www.microsoft.com" Grid.Row="1" Grid.Column="1" />
        </Grid>

    Thursday, November 13, 2014 5:44 PM
    Owner