如何在 WP8 WebBrowser 控件加载 URL 之前显示进度条? [英] How to show progressbar until WP8 WebBrowser control loaded the URL?

查看:25
本文介绍了如何在 WP8 WebBrowser 控件加载 URL 之前显示进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WebBrowser 控件,我想在这个控件上显示一些 url.在浏览器加载页面之前,我需要显示一些进度条或动画.

I have a WebBrowser control and I want to show some url on this control. Until the webbrower loaded the page, I need to show some progressbar or animation.

请帮助我,这是我所拥有的:

Please help me, here's what I have:

XAML:

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <ProgressBar x:Name="progressbar" IsIndeterminate="True"/>
    <phone:WebBrowser x:Name="webbrw" IsScriptEnabled="True"/>
</Grid>

强文本

public MainPage()
{
    InitializeComponent();

    // Sample code to localize the ApplicationBar
    //BuildLocalizedApplicationBar();
    Loaded += MainPage_Loaded;
}

void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    webbrw.LoadCompleted += webbrw_LoadCompleted;
    webbrw.Source = new Uri("http://www.youtube.com/user/tseries");
}

void webbrw_LoadCompleted(object sender, NavigationEventArgs e)
{
    progressbar.IsIndeterminate = false;
}

推荐答案

如果您只是想在加载页面时显示栏并在之后隐藏它,您'重新使用错误的属性.IsIndeterminate 属性报告通用进程 (true) 或基于值 (false) 的进程.要隐藏您应该使用的进度条:

If you simply want to show the bar while loading the page and hide it afterwards, you're using the wrong property. The IsIndeterminate property reports a generic process (true) or one based on a value (false). To hide the progressbar you should use:

progressbar.Visibility = Visibility.Collapsed; 

这篇关于如何在 WP8 WebBrowser 控件加载 URL 之前显示进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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