在添加并完全显示布局后加载函数

时间:2014-11-25 14:31:36

标签: c# windows-phone-8

我正在尝试在Windows Phone 8.1中显示加载页面

我希望在看到布局后调用函数this.GetAllRings。我已尝试添加加载但它仍然无法正常工作。除非整个查询完成,否则我会看到黑屏。我该如何解决这个问题

以下是我的代码

public MainPage()
    {
        this.InitializeComponent();
        this.app = App.Current as App;
        this.Loaded += MainPage_Loaded;

        this.NavigationCacheMode = NavigationCacheMode.Disabled;
    }

    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {            
        this.GetAllRings();
    }

1 个答案:

答案 0 :(得分:1)

在您的MainPage_Loaded方法中,您的请求可能阻止了UI线程。 您应该尝试以下方法:

await Task.Run(() => this.GetAllRings());

这应该这样做。