Windows应用程序进度条

时间:2015-04-02 19:13:04

标签: c# windows xaml windows-applications

我使用Windows应用程序模板创建webview并在该webView中加载我的响应式网站。我尝试使用ProgressRing向用户显示应用程序正在加载,直到页面完全加载。 ProgressRing即将到来,但不会消失。以下是我的应用程序的实际代码。

快速帮助将受到高度赞赏。谢谢!

MainPage.xaml中:

x:Class="Zify.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Zify"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
    <WebView Name="webView1" HorizontalAlignment="Left" VerticalAlignment="Top" Height="650" Width="400"/>
    <ProgressRing Name="progress" " IsActive="True" Foreground="#FFE74C3A"/>

MainPage.xaml.cs中:

namespace Zify
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Required;
            Uri targetUri = new Uri(@"https://zify.com/index.htm");
            webView1.Navigate(targetUri);
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>

        // Event handler for the system's DisplaySettingsChanged event.
        // Detect and then compare the height and width of the screen.
    }
}

2 个答案:

答案 0 :(得分:0)

将Grid.Row =“1”添加到ProgressRing

答案 1 :(得分:0)

尝试添加此行以将控件转移到事件,该事件确定Webview控件是否已完全加载网页。

WebView1.LoadCompleted += new Windows.UI.Xaml.Navigation.LoadCompletedEventHandler(WebView1_LoadCompleted);

然后在Progress Bar完全装满后停止!

void WebView1_LoadCompleted(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
 //code for hiding progress bar/ring
 ProgressRing1.IsActive = false; //for progress ring
 ProgressBar1.IsIndeterminate = false; //for progress bar
}

来源:show progress bar/ring in windows 8 app while a webpage is loading in webview control