积极答复者
WebViewBrush

问题
-
<StackPanel Orientation="Horizontal">
<Grid Width="400" Height="400" >
<WebView x:Name="http" Source="http://www.baidu.com"/>
</Grid>
<Grid Width="400" Height="400">
<Grid.Background>
<WebViewBrush SourceName="http" Stretch="Fill"></WebViewBrush>
</Grid.Background>
</Grid>
<Rectangle Width="400" Height="400">
<Rectangle.Fill>
<WebViewBrush SourceName="http"/>
</Rectangle.Fill>
</Rectangle>
</StackPanel>这个Demo中,为什么有时WebViewBrush会显示不出来?有时候能显示出来
答案
-
你好。
可以尝试把WebViewBrush的赋值放在WebView加载完成事件中。代码这样修改:
<StackPanel Orientation="Horizontal"> <Grid Width="400" Height="400"> <WebView x:Name="http" Source="http://www.baidu.com" LoadCompleted="http_LoadCompleted"/> </Grid> <Grid Width="400" Height="400"> <Grid.Background> <WebViewBrush x:Name="wvb1" Stretch="Fill"></WebViewBrush> </Grid.Background> </Grid> <Rectangle Width="400" Height="400"> <Rectangle.Fill> <WebViewBrush x:Name="wvb2"/> </Rectangle.Fill> </Rectangle> </StackPanel>
后台代码:
private void http_LoadCompleted(object sender, NavigationEventArgs e) { wvb1.SetSource(http); wvb2.SetSource(http); }
- 已标记为答案 runqian 2014年7月15日 8:42
全部回复
-
你好。
可以尝试把WebViewBrush的赋值放在WebView加载完成事件中。代码这样修改:
<StackPanel Orientation="Horizontal"> <Grid Width="400" Height="400"> <WebView x:Name="http" Source="http://www.baidu.com" LoadCompleted="http_LoadCompleted"/> </Grid> <Grid Width="400" Height="400"> <Grid.Background> <WebViewBrush x:Name="wvb1" Stretch="Fill"></WebViewBrush> </Grid.Background> </Grid> <Rectangle Width="400" Height="400"> <Rectangle.Fill> <WebViewBrush x:Name="wvb2"/> </Rectangle.Fill> </Rectangle> </StackPanel>
后台代码:
private void http_LoadCompleted(object sender, NavigationEventArgs e) { wvb1.SetSource(http); wvb2.SetSource(http); }
- 已标记为答案 runqian 2014年7月15日 8:42