Windows phone 7 垂直拉伸WebBrowser以适应内部内容
当我有一个WebBrowser控件时,我的页面布局出现了一些问题 以下是我的XAML的重要部分:Windows phone 7 垂直拉伸WebBrowser以适应内部内容,windows-phone-7,xaml,Windows Phone 7,Xaml,当我有一个WebBrowser控件时,我的页面布局出现了一些问题 以下是我的XAML的重要部分: <Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefi
<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 streatch。将其属性设置为“自动”没有帮助。如果这样做,则默认高度为0
有什么想法吗?使用网格代替StackPanel,并将第二行的高度设置为“*”,如下所示:
<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下面添加控件,这会起作用吗?是的,您只需要在网格中添加更多行,然后将WebBrowser设置为第一行,将其他元素设置为其他行。明白了。今晚我回家后会试试。对我来说,它在WP8上也不起作用-当我启动应用程序时,浏览器控件完全不可见。有人有更好的答案吗?