SuperJMN
SuperJMN

Reputation: 13992

Adding a Button below a WebView

I have to show a fragment of text formatted in HTML (a terms and conditions text). Below this text, there should be a Button to accept them.

Of course, the user should scroll down to the bottom before accepting the terms, so the button should be just under the terms & conditions text.

I have used a WebView to render the HTML, but it has a big problem: When I put it inside a StackPanel, it collapses its height to zero. So, nothing is shown. This is the XAML to reproduce the problem.

<StackPanel>
    <WebView />
    <Button>Accept</Button>
</StackPanel>

This doesn't happen when the container is a Grid, because it expands to fill the whole space. However, with a Grid I cannot make the Button appear under the text.

What can I do to make this work?

Upvotes: 1

Views: 308

Answers (1)

Marian Dolinsk&#253;
Marian Dolinsk&#253;

Reputation: 3492

You should add Rows to the Grid:

<Grid>
    <Grid.RowDefinitions>
        <!-- This row will be stretched -->
        <RowDefinition Height="*"/>

        <!-- The size of this row is determined by the size properties of the content object. -->
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <WebView Grid.Row="0"/>
    <Button Grid.Row="1">Accept</Button>
</Grid>

Take a look here for more info about layout panels in UWP.

Upvotes: 1

Related Questions