垂直拉伸 WebBrowser 以适应内容 [英] Vertical stretch WebBrowser to fit content inside

查看:20
本文介绍了垂直拉伸 WebBrowser 以适应内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有一个 WebBrowser 控件时,我在页面布局方面遇到了一些问题.

I've been having some issues with the layout of a page when I have a WebBrowser control in it.

这是我的 XAML 的重要部分:

Here's the significant portion of my XAML:

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,12">
        <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="{Binding Title}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <StackPanel Grid.Row="1" Margin="12,17,0,12">
        <phone:WebBrowser Name="HtmlBody" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Red" Margin="12,17,0,28"/>
    </StackPanel>
</Grid>

我的问题是如何制作 WebBrowser 拉伸.将其属性设置为 auto 无济于事.如果我这样做,它的默认高度为 0.

My question is how do I make the WebBrowser streatch. Setting it's properties to auto doesn't help. If I do that it defaults to a height of 0.

有什么想法吗?

推荐答案

使用 Grid 而不是 StackPanel,并将第二行的高度设置为*",如下所示:

Use Grid instead of the StackPanel, and set the height of the second row to "*", like this:

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,12">
        <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="{Binding Title}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid Grid.Row="1" Margin="12,17,0,12">
        <phone:WebBrowser Name="HtmlBody" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Red" Margin="12,17,0,28"/>
    </Grid>
</Grid>

这篇关于垂直拉伸 WebBrowser 以适应内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆