如何重置页面加载时所做的点击

时间:2014-09-16 13:12:07

标签: windows-store-apps windows-8.1

我有窗口商店应用程序。我尝试导航到一个加载一段时间(几秒钟)的页面。该页面包含几张大图片,因此它会加载一段时间,特别是在弱设备上。在页面加载时单击时出现问题 - 加载页面时将处理单击。如果用户点击加载页面时将成为按钮的点,将单击按钮。

如何关闭此功能?有没有办法在加载时重置点击次数?

1 个答案:

答案 0 :(得分:0)

可以通过更好的设计方法来处理,而不是重置页面加载的点击次数。

在页面加载时,显示一个不确定的进度条,一旦图像加载完成,隐藏进度条并显示您的实际屏幕。

下面是一个通过将进度条放在PopUp控件中来实现此目的的示例 navigationHelper_LoadState(object sender,LoadStateEventArgs e)事件

        //Progress Bar
        ProgressBar bar = new ProgressBar();
        bar.IsIndeterminate = true;

        //Downloading Data text
        TextBlock txt = new TextBlock();
        txt.Text = "Downloading data...";
        txt.FontSize = 17;
        txt.Foreground = new SolidColorBrush(Colors.White);
        txt.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;

        //This could take a few seconds
        TextBlock txt2 = new TextBlock();
        txt2.Text = "This could take a few seconds.";
        txt2.FontSize = 17;
        txt2.Foreground = new SolidColorBrush(Colors.White);
        txt2.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;

        //Please do not close the application.
        TextBlock txt3 = new TextBlock();
        txt3.Text = "Please do not close the application.";
        txt3.FontSize = 17;
        txt3.Foreground = new SolidColorBrush(Colors.White);
        txt3.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;

        StackPanel stk = new StackPanel();
        stk.Children.Add(bar);
        stk.Children.Add(txt);
        stk.Children.Add(txt2);
        stk.Children.Add(txt3);

        stk.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
        Grid contentGrid = new Grid();
        contentGrid.Height = Window.Current.Bounds.Height;
        contentGrid.Width = Window.Current.Bounds.Width;
        // or from LayoutGrid
        //contentGrid.Height = LayoutRoot.ActualHeight;
        //contentGrid.Width = LayoutRoot.ActualWidth;
        contentGrid.Width -= 40; // it seems that ContentDialog has some defaul margin
        contentGrid.Children.Add(stk);

        Popup dlg = new Popup();
        dlg.Child = contentGrid;
        SolidColorBrush color = new SolidColorBrush(Colors.Black);
        color.Opacity = 0.7;
        //dlg.Background = color;
        dlg.IsOpen = true;

图片加载后,您可以选择关闭此PopUp