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

本文关键字:布局 加载 函数 显示 添加 | 更新日期: 2023-09-27 18:31:58

我正在尝试在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();
    }

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

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

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

这应该可以做到。