如何在 windows phone 8.1 中拉伸 webview 的高度?
How to stretch the height of a webview in windows phone 8.1?
我得到一个页面,其中的文本块和网络视图中有一个网格。
我找不到让 webview 填充页面的方法,带有“*”或水平拉伸的事件。
我必须设置一个 minHeight 才能看到 webview,因为如果我没有设置高度,它是不可见的(我猜高度是 0)。
<ScrollViewer x:Name="scrollViewer" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Name="title" MaxLines="1" TextTrimming="CharacterEllipsis" Margin="10" TextAlignment="Left" TextWrapping="Wrap" Foreground="Black" FontSize="30" FontWeight="Bold"/>
<StackPanel Grid.Row="1" Background="Black" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<WebView MinHeight="600"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
x:Name="webview"
Margin="10" />
</StackPanel>
</Grid>
</ScrollViewer>
这是我的cs代码
webview.NavigateToString("<HEAD>" +
"<style type=\"text/css\">body{color: #fff; background-color: #000; overflow-x: hidden;" + fontSize + "}</style>" +
"<TITLE>title</TITLE></HEAD><BODY>" + text + "</BODY>");
感谢您的帮助。
尝试移除堆栈面板并将高度设置为自动
<ScrollViewer x:Name="scrollViewer">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Name="title" MaxLines="1"
TextTrimming="CharacterEllipsis"
Margin="10" TextAlignment="Left"
TextWrapping="Wrap" Foreground="Black"
FontSize="30" FontWeight="Bold" />
<Grid Background="Black"
Margin="10"
Grid.Row="1">
<WebView ScrollViewer.ZoomMode="Disabled"
x:Name="webview"
Margin="10"
Height="Auto" />
</Grid>
</Grid>
</ScrollViewer>
<ScrollViewer x:Name="scrollViewer" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Name="title" MaxLines="1" TextTrimming="CharacterEllipsis" Margin="10" TextAlignment="Left" TextWrapping="Wrap" Foreground="Black" FontSize="30" FontWeight="Bold"/>
<WebView MinHeight="600" Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
x:Name="webview"
Margin="10" />
</Grid>
</ScrollViewer>
我得到一个页面,其中的文本块和网络视图中有一个网格。
我找不到让 webview 填充页面的方法,带有“*”或水平拉伸的事件。
我必须设置一个 minHeight 才能看到 webview,因为如果我没有设置高度,它是不可见的(我猜高度是 0)。
<ScrollViewer x:Name="scrollViewer" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Name="title" MaxLines="1" TextTrimming="CharacterEllipsis" Margin="10" TextAlignment="Left" TextWrapping="Wrap" Foreground="Black" FontSize="30" FontWeight="Bold"/>
<StackPanel Grid.Row="1" Background="Black" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<WebView MinHeight="600"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
x:Name="webview"
Margin="10" />
</StackPanel>
</Grid>
</ScrollViewer>
这是我的cs代码
webview.NavigateToString("<HEAD>" +
"<style type=\"text/css\">body{color: #fff; background-color: #000; overflow-x: hidden;" + fontSize + "}</style>" +
"<TITLE>title</TITLE></HEAD><BODY>" + text + "</BODY>");
感谢您的帮助。
尝试移除堆栈面板并将高度设置为自动
<ScrollViewer x:Name="scrollViewer">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Name="title" MaxLines="1"
TextTrimming="CharacterEllipsis"
Margin="10" TextAlignment="Left"
TextWrapping="Wrap" Foreground="Black"
FontSize="30" FontWeight="Bold" />
<Grid Background="Black"
Margin="10"
Grid.Row="1">
<WebView ScrollViewer.ZoomMode="Disabled"
x:Name="webview"
Margin="10"
Height="Auto" />
</Grid>
</Grid>
</ScrollViewer>
<ScrollViewer x:Name="scrollViewer" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Name="title" MaxLines="1" TextTrimming="CharacterEllipsis" Margin="10" TextAlignment="Left" TextWrapping="Wrap" Foreground="Black" FontSize="30" FontWeight="Bold"/>
<WebView MinHeight="600" Grid.Row="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.ZoomMode="Disabled"
x:Name="webview"
Margin="10" />
</Grid>
</ScrollViewer>