How to show the ProgressBar control while the page is loading?

I have a WP7 application with multiple pages. When the user navigates through them, it takes some time to download information. Therefore, before showing him / her the page, I would like to show the message "Loading ...". I created a progress bar and placed it on the page:

    <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>

And I'm trying to show it (and hide everything else) in the page constructor and hide it (and show everything else) in the Page.Loaded handler.

    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;
    }

But it does not work. Any ideas? Thank!

+3
source share
3 answers

Alex shows a progress bar when the application launches here.

WP7. -

+2

(), (, , Alex) background (read: loading).

0

, XAML, . Splash Screens, MSDN:

0

Source: https://habr.com/ru/post/1776130/


All Articles