简体   繁体   English

在添加布局并完整显示后加载功能

[英]Load a function after the layout is being added and shown completely

I am trying to show a loading page in windows phone 8.1 我正在尝试在Windows Phone 8.1中显示加载页面

I want to call function this.GetAllRings after i can see the layout. 我想在看到布局后调用函数this.GetAllRings I have tried added in loaded but it still don't work. 我曾尝试在加载中添加内容,但仍然无法正常工作。 Unless the entire query is complete, i see black screen. 除非整个查询完成,否则我会看到黑屏。 How can i fix this 我怎样才能解决这个问题

Following is my code 以下是我的代码

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

In your MainPage_Loaded method your request is probably blocking the UI thread. 在MainPage_Loaded方法中,您的请求可能会阻止UI线程。 You should try the following: 您应该尝试以下方法:

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

This should do it. 这应该做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM