private async void Window_Loaded(object sender, RoutedEventArgs e) { ModelManager modelMgr = ModelManager.GetInstance(); if (!await modelMgr.Initialize()) { MessageBox.Show("Failed to authenticate.", null, MessageBoxButton.OK, MessageBoxImage.Error); Close(); return; } List <TenantModel> tenantModels = await modelMgr.GetTenantModels(); if (tenantModels.Count <= 0) { MessageBox.Show("No azure sphere tenant found.", null, MessageBoxButton.OK, MessageBoxImage.Error); Close(); return; } else if (tenantModels.Count == 1) { CurrentTenantModel = tenantModels[0]; } else { var dialog = new TenantsWindow(); dialog.Owner = this; dialog.TenantModels = tenantModels; var dialogResult = dialog.ShowDialog(); if (!dialogResult.Value) { Close(); return; } CurrentTenantModel = dialog.SelectedTenantModel; } // EventHandler var roles = await modelMgr.GetRolesAsync(CurrentTenantModel.Context, modelMgr.GetUsername()); if (roles.Contains("Administrator")) { menuitemUsers.IsEnabled = true; } modelMgr.NotificationChangeProduct += NotificationChangeProduct; modelMgr.NotificationChangeDeviceGroup += NotificationChangeDeviceGroup; modelMgr.NotificationChangeDevice += NotificationChangeDevice; await RefreshAllGrids(); }