手机:WebBrowser我们如何设置自动高度和宽度?

时间:2014-09-03 12:25:58

标签: windows-phone-7 windows-phone-8

   <StackPanel Orientation="Vertical">

                <TextBlock x:Name="articleDate" Foreground="Black" FontSize="20" 
                           Text="Timefzdsaf" />
                <Image x:Name="image" Stretch="Uniform" />
                <StackPanel Orientation="Vertical">
                <phone:WebBrowser Name="webBrowser1"                            
                          IsScriptEnabled="False"  Background="White"
                          HorizontalAlignment="Stretch"   
                          VerticalAlignment="Stretch"
                          VerticalContentAlignment="Center" 
                          HorizontalContentAlignment="Center" 

                        ></phone:WebBrowser>



            </StackPanel>

电话:WebBrowser不会显示在我的页面中(如果没有给出高度和宽度,我希望它应该自动进行)。任何人都可以帮我在手机WebBrowser中显示HTML吗?

1 个答案:

答案 0 :(得分:1)

不要使用StackPanel。尝试使用RowDefinitions的Grid。对于WebBrowser,将其设置为“*”

从您的代码中添加来源(仅用于演示):

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <TextBlock x:Name="articleDate" 
                       Foreground="Black" 
                       FontSize="20" 
                       Text="Timefzdsaf" />
            <Image x:Name="image"
                   Grid.Row="1"
                   Stretch="Uniform" />
            <phone:WebBrowser Name="webBrowser1"  
                              Source="http://msdn.microsoft.com/en-US/"
                              IsScriptEnabled="False"  
                              Grid.Row="2"
                              Background="White"
                              HorizontalAlignment="Stretch"   
                              VerticalAlignment="Stretch"
                              VerticalContentAlignment="Center" 
                              HorizontalContentAlignment="Center">
            </phone:WebBrowser>
        </Grid>