/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static void Initialize(Package package, ViewModelLocator vmLocator, INanoDeviceCommService nanoDeviceCommService) { Instance = new DeviceExplorerCommand(package); Instance.ViewModelLocator = vmLocator; Instance.NanoDeviceCommService = nanoDeviceCommService; //windowApp = (); Instance.CreateToolbarHandlers(); // setup message listeners to be notified of events occurring in the View Model Messenger.Default.Register <NotificationMessage>(Instance, DeviceExplorerViewModel.MessagingTokens.SelectedNanoDeviceHasChanged, (message) => Instance.SelectedNanoDeviceHasChangedHandler()); Messenger.Default.Register <NotificationMessage>(Instance, DeviceExplorerViewModel.MessagingTokens.NanoDevicesCollectionHasChanged, (message) => Instance.NanoDevicesCollectionChangedHandler()); }
/// <summary> /// Initializes the singleton instance of the command. /// </summary> /// <param name="package">Owner package, not null.</param> public static async Task InitializeAsync(AsyncPackage package, ViewModelLocator vmLocator, INanoDeviceCommService nanoDeviceCommService) { s_instance = new DeviceExplorerCommand(package); s_instance.ViewModelLocator = vmLocator; s_instance.NanoDeviceCommService = nanoDeviceCommService; //windowApp = (); // need to switch to the main thread to initialize the command handlers await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); s_instance.CreateToolbarHandlers(); // setup message listeners to be notified of events occurring in the View Model Messenger.Default.Register <NotificationMessage>(s_instance, DeviceExplorerViewModel.MessagingTokens.SelectedNanoDeviceHasChanged, (message) => s_instance.SelectedNanoDeviceHasChangedHandler()); Messenger.Default.Register <NotificationMessage>(s_instance, DeviceExplorerViewModel.MessagingTokens.NanoDevicesCollectionHasChanged, (message) => s_instance.NanoDevicesCollectionChangedHandler()); }