【问题标题】:How to show ProgressBar control while a page is loading?如何在页面加载时显示 ProgressBar 控件?
【发布时间】:2010-11-22 00:17:18
【问题描述】:

我有几个页面的 WP7 应用程序。当用户浏览它们时,加载信息需要一些时间。因此,在向他/她显示页面之前,我想显示“正在加载...”消息。 我创建了进度条并将其放在页面上:

    <StackPanel x:Name="progressBarMain" Grid.Row="1" Grid.ColumnSpan="2" Visibility="Collapsed">
        <TextBlock Text="Loading..." HorizontalAlignment="Center" VerticalAlignment="Center" />
        <ProgressBar Margin="10" Height="30" IsIndeterminate="True"/>
    </StackPanel>

我试图在页面的构造函数中显示它(并隐藏其他所有内容),并在 Page.Loaded 处理程序中隐藏它(并显示其他所有内容)。

    public SomePage()
    {
        InitializeComponent();

        Loaded +=OnSomePageLoaded;
        progressBarMain.Visibility = Visibility.Visible;
        ContentPanel.Visibility = Visibility.Collapsed;
    }

    private void OnSomePageLoaded(object sender, RoutedEventArgs e)
    {
        progressBarMain.Visibility = Visibility.Collapsed;
        ContentPanel.Visibility = Visibility.Visible;
    }

但它不起作用。 有任何想法吗?谢谢!

【问题讨论】:

    标签: c# windows-phone-7 progress-bar


    【解决方案1】:

    Alex 在此处演示了在应用启动时显示进度条。

    Creating a Splash Screen with a progress bar for WP7 applications. - Alex Yakhnin's Blog

    【讨论】:

    【解决方案2】:

    虽然您不能直接操作启动画面(它是静态的),但您可以显示一个弹出窗口(顺便说一下,这正是 Alex 的解决方案中所做的)并等待后台(读取:加载)操作完成.

    【讨论】:

      【解决方案3】:

      是的,您需要创建一个单独的 XAML 弹出页面,该页面会在应用启动时加载。有关启动画面的更多详细信息,请参阅 MSDN 的代码示例:

      "Code Sample for Splash Screen"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-02-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-08
        • 1970-01-01
        相关资源
        最近更新 更多