【问题标题】:Xamarin Forms Update ListView on WillEnterForegroundWillEnterForeground 上的 Xamarin 表单更新 ListView
【发布时间】:2015-02-02 19:03:58
【问题描述】:

目标

iOS 应用程序进入前台时更新 Xamarin.Forms ListView

接近

我在单点触控示例中看到的关闭示例

https://github.com/xamarin/monotouch-samples/blob/master/SimpleBackgroundFetch/SimpleBackgroundFetch/AppDelegate.cs

public override void PerformFetch (UIApplication application, Action<UIBackgroundFetchResult> completionHandler)
        {
            UINavigationController navigationController = Window.RootViewController as UINavigationController;
            UIViewController topViewController = navigationController.TopViewController;
            if (topViewController is RootViewController) {
                (topViewController as RootViewController).InsertNewObjectForFetch (completionHandler);
                UIApplication.SharedApplication.ApplicationIconBadgeNumber++;
            } else
                completionHandler (UIBackgroundFetchResult.Failed);
        }

这是使用 PerformFetch 但 WillEnterForegroundMethod 将完成我想要做的事情。

问题

问题是我正在使用 Xamarin.Form 页面,但不知道如何从 App Delegate 类访问页面或页面的 ViewModel。有什么想法吗?

【问题讨论】:

    标签: c# xamarin.ios xamarin xamarin.forms


    【解决方案1】:

    当您将 ViewModel 设置为 View 的 BindingContext 时,您可以将 ViewModel 注册到 IoC 容器,然后使用它来获取它。

    如果您使用的是 MVVMLight,SimpleIoC 包含在该软件包中。

    【讨论】:

      猜你喜欢
      • 2018-08-14
      • 1970-01-01
      • 2018-03-11
      • 2019-09-19
      • 2019-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多