public static void Init() { if (IsInitialized) { return; } IsInitialized = true; Color.SetAccent(Color.FromRgba(50, 79, 133, 255)); Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); #if __MOBILE__ Device.SetIdiom(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? TargetIdiom.Tablet : TargetIdiom.Phone); Device.SetFlowDirection(UIApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); #else Device.SetIdiom(TargetIdiom.Desktop); Device.SetFlowDirection(NSApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); var mojave = new NSOperatingSystemVersion(10, 14, 0); if (NSProcessInfo.ProcessInfo.IsOperatingSystemAtLeastVersion(mojave) && typeof(NSApplication).GetProperty("Appearance") is PropertyInfo appearance && appearance != null) { var aquaAppearance = NSAppearance.GetAppearance(NSAppearance.NameAqua); appearance.SetValue(NSApplication.SharedApplication, aquaAppearance); } #endif Device.SetFlags(s_flags); Device.PlatformServices = new IOSPlatformServices(); Device.Info = new IOSDeviceInfo(); Internals.Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); ExpressionSearch.Default = new iOSExpressionSearch(); }
public static void Init() { if (IsInitialized) { return; } IsInitialized = true; Color.SetAccent(Color.FromRgba(50, 79, 133, 255)); Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); #if __MOBILE__ Device.SetIdiom(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? TargetIdiom.Tablet : TargetIdiom.Phone); Device.SetFlowDirection(UIApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); #else Device.SetIdiom(TargetIdiom.Desktop); Device.SetFlowDirection(NSApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); #endif Device.SetFlags(s_flags); Device.PlatformServices = new IOSPlatformServices(); Device.Info = new IOSDeviceInfo(); Internals.Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); ExpressionSearch.Default = new iOSExpressionSearch(); }
public static void Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } var accent = (SolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; Color.SetAccent(accent.ToFormsColor()); Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); Device.PlatformServices = new WindowsPlatformServices(Window.Current.Dispatcher); Device.SetFlags(s_flags); Device.Info = new WindowsDeviceInfo(); switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Desktop": if (Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode == Windows.UI.ViewManagement.UserInteractionMode.Touch) { Device.SetIdiom(TargetIdiom.Tablet); } else { Device.SetIdiom(TargetIdiom.Desktop); } break; case "Windows.Mobile": Device.SetIdiom(TargetIdiom.Phone); break; case "Windows.Xbox": Device.SetIdiom(TargetIdiom.TV); break; default: Device.SetIdiom(TargetIdiom.Unsupported); break; } ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); IsInitialized = true; s_state = launchActivatedEventArgs.PreviousExecutionState; Platform.UWP.Platform.SubscribeAlertsAndActionSheets(); }
public static void Init(IActivatedEventArgs launchActivatedEventArgs) #endif { if (IsInitialized) { return; } var accent = (SolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; Color.SetAccent(Color.FromRgba(accent.Color.R, accent.Color.G, accent.Color.B, accent.Color.A)); Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); Device.PlatformServices = new WindowsPlatformServices(Window.Current.Dispatcher); #if WINDOWS_UWP Device.SetFlags(s_flags); #endif Device.Info = new WindowsDeviceInfo(); #if WINDOWS_UWP switch (DetectPlatform()) { case Windows.Foundation.Metadata.Platform.Windows: Device.SetIdiom(TargetIdiom.Desktop); break; case Windows.Foundation.Metadata.Platform.WindowsPhone: Device.SetIdiom(TargetIdiom.Phone); break; default: Device.SetIdiom(TargetIdiom.Tablet); break; } #endif ExpressionSearch.Default = new WindowsExpressionSearch(); #if WINDOWS_UWP Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); #endif Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); IsInitialized = true; s_state = launchActivatedEventArgs.PreviousExecutionState; #if WINDOWS_UWP SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; Platform.UWP.Platform.SubscribeAlertsAndActionSheets(); #endif }
public static void Init() { if (IsInitialized) { return; } IsInitialized = true; Internals.Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); Color.SetAccent(ColorExtensions.AccentColor.ToColor()); Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); #if __MOBILE__ Device.SetIdiom(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? TargetIdiom.Tablet : TargetIdiom.Phone); Device.SetFlowDirection(UIApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); #else // Subscribe to notifications in OS Theme changes NSDistributedNotificationCenter.GetDefaultCenter().AddObserver((NSString)"AppleInterfaceThemeChangedNotification", (n) => { var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle"); var aquaAppearance = NSAppearance.GetAppearance(interfaceStyle == "Dark" ? NSAppearance.NameDarkAqua : NSAppearance.NameAqua); NSApplication.SharedApplication.Appearance = aquaAppearance; Application.Current?.TriggerThemeChanged(new AppThemeChangedEventArgs(interfaceStyle == "Dark" ? OSAppTheme.Dark : OSAppTheme.Light)); }); Device.SetIdiom(TargetIdiom.Desktop); Device.SetFlowDirection(NSApplication.SharedApplication.UserInterfaceLayoutDirection.ToFlowDirection()); if (IsMojaveOrNewer) { var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle"); var aquaAppearance = NSAppearance.GetAppearance(interfaceStyle == "Dark" ? NSAppearance.NameDarkAqua : NSAppearance.NameAqua); NSApplication.SharedApplication.Appearance = aquaAppearance; } #endif Device.SetFlags(s_flags); var platformServices = new IOSPlatformServices(); Device.PlatformServices = platformServices; #if __MOBILE__ Device.PlatformInvalidator = platformServices; Device.Info = new IOSDeviceInfo(); #else Device.Info = new Platform.macOS.MacDeviceInfo(); #endif Internals.Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportFontAttribute) }); ExpressionSearch.Default = new iOSExpressionSearch(); }
public static void InitHeadless(IActivatedEventArgs launchActivatedEventArgs, IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); Device.PlatformServices = new WindowsPlatformServices(CoreWindow.GetForCurrentThread().Dispatcher); Device.SetFlags(s_flags); Device.Info = new WindowsDeviceInfo(); ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); IsInitialized = true; s_state = launchActivatedEventArgs.PreviousExecutionState; }
static void SetupInit( Context activity, Assembly resourceAssembly, InitializationOptions?maybeOptions = null ) { Profile.FrameBegin(); Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim); if (!IsInitialized) { // Only need to get this once; it won't change ApplicationContext = activity.ApplicationContext; } #pragma warning disable 618 // Still have to set this up so obsolete code can function Context = activity; #pragma warning restore 618 if (!IsInitialized) { // Only need to do this once Profile.FramePartition("ResourceManager.Init"); ResourceManager.Init(resourceAssembly); } Profile.FramePartition("Color.SetAccent()"); // We want this to be updated when we have a new activity (e.g. on a configuration change) // This could change if the UI mode changes (e.g., if night mode is enabled) Color.SetAccent(GetAccentColor(activity)); _ColorButtonNormalSet = false; if (!IsInitialized) { // Only need to do this once Profile.FramePartition("Log.Listeners"); Internals.Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because AndroidPlatformServices needs a current activity to launch URIs from Profile.FramePartition("Device.PlatformServices"); var androidServices = new AndroidPlatformServices(activity); Device.PlatformServices = androidServices; Device.PlatformInvalidator = androidServices; // use field and not property to avoid exception in getter if (Device.info != null) { ((AndroidDeviceInfo)Device.info).Dispose(); Device.info = null; } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because Device.Info watches for orientation changes and we need a current activity for that Profile.FramePartition("create AndroidDeviceInfo"); Device.Info = new AndroidDeviceInfo(activity); Profile.FramePartition("setFlags"); Device.SetFlags(s_flags); Profile.FramePartition("AndroidTicker"); Ticker.SetDefault(null); Profile.FramePartition("RegisterAll"); if (!IsInitialized) { if (maybeOptions.HasValue) { var options = maybeOptions.Value; var handlers = options.Handlers; var flags = options.Flags; var effectScopes = options.EffectScopes; //TODO: ExportCell? //TODO: ExportFont // renderers Registrar.RegisterRenderers(handlers); // effects if (effectScopes != null) { for (var i = 0; i < effectScopes.Length; i++) { var effectScope = effectScopes[0]; Registrar.RegisterEffects(effectScope.Name, effectScope.Effects); } } // css Registrar.RegisterStylesheets(flags); } else { // Only need to do this once Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportFontAttribute) }); } } Profile.FramePartition("Epilog"); var currentIdiom = TargetIdiom.Unsupported; // First try UIModeManager using (var uiModeManager = UiModeManager.FromContext(ApplicationContext)) { try { var uiMode = uiModeManager?.CurrentModeType ?? UiMode.TypeUndefined; currentIdiom = DetectIdiom(uiMode); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Unable to detect using UiModeManager: {ex.Message}"); } } // Then try Configuration if (TargetIdiom.Unsupported == currentIdiom) { var configuration = activity.Resources.Configuration; if (configuration != null) { var minWidth = configuration.SmallestScreenWidthDp; var isWide = minWidth >= TabletCrossover; currentIdiom = isWide ? TargetIdiom.Tablet : TargetIdiom.Phone; } else { // Start clutching at straws var metrics = activity.Resources?.DisplayMetrics; if (metrics != null) { var minSize = Math.Min(metrics.WidthPixels, metrics.HeightPixels); var isWide = minSize * metrics.Density >= TabletCrossover; currentIdiom = isWide ? TargetIdiom.Tablet : TargetIdiom.Phone; } } } Device.SetIdiom(currentIdiom); if (SdkInt >= BuildVersionCodes.JellyBeanMr1) { Device.SetFlowDirection(activity.Resources.Configuration.LayoutDirection.ToFlowDirection()); } if (ExpressionSearch.Default == null) { ExpressionSearch.Default = new AndroidExpressionSearch(); } IsInitialized = true; Profile.FrameEnd(); }
static void SetupInit( Context activity, Assembly resourceAssembly, ActivationOptions?maybeOptions = null ) { Profile.FrameBegin(); if (!IsInitialized) { // Only need to get this once; it won't change ApplicationContext = activity.ApplicationContext; } #pragma warning disable 618 // Still have to set this up so obsolete code can function Context = activity; #pragma warning restore 618 if (!IsInitialized) { // Only need to do this once Profile.FramePartition("ResourceManager.Init"); ResourceManager.Init(resourceAssembly); } Profile.FramePartition("Color.SetAccent()"); // We want this to be updated when we have a new activity (e.g. on a configuration change) // This could change if the UI mode changes (e.g., if night mode is enabled) Color.SetAccent(GetAccentColor(activity)); _ColorButtonNormalSet = false; if (!IsInitialized) { // Only need to do this once Profile.FramePartition("Log.Listeners"); Internals.Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because AndroidPlatformServices needs a current activity to launch URIs from Profile.FramePartition("Device.PlatformServices"); Device.PlatformServices = new AndroidPlatformServices(activity); // use field and not property to avoid exception in getter if (Device.info != null) { ((AndroidDeviceInfo)Device.info).Dispose(); Device.info = null; } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because Device.Info watches for orientation changes and we need a current activity for that Profile.FramePartition("new AndroidDeviceInfo(activity)"); Device.Info = new AndroidDeviceInfo(activity); Device.SetFlags(s_flags); Profile.FramePartition("AndroidTicker"); var ticker = Ticker.Default as AndroidTicker; if (ticker != null) { ticker.Dispose(); } Ticker.SetDefault(new AndroidTicker()); Profile.FramePartition("RegisterAll"); if (!IsInitialized) { if (maybeOptions.HasValue) { var options = maybeOptions.Value; var handlers = options.Handlers; var flags = options.Flags; var effectScopes = options.EffectScopes; // renderers Registrar.RegisterRenderers(handlers); // effects if (effectScopes != null) { for (var i = 0; i < effectScopes.Length; i++) { var effectScope = effectScopes[0]; Registrar.RegisterEffects(effectScope.Name, effectScope.Effects); } } // css var noCss = (flags & ActivationFlags.NoCss) != 0; if (!noCss) { Registrar.RegisterStylesheets(); } } else { // Only need to do this once Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); } } Profile.FramePartition("Epilog"); // This could change as a result of a config change, so we need to check it every time int minWidthDp = activity.Resources.Configuration.SmallestScreenWidthDp; Device.SetIdiom(minWidthDp >= TabletCrossover ? TargetIdiom.Tablet : TargetIdiom.Phone); if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1) { Device.SetFlowDirection(activity.Resources.Configuration.LayoutDirection.ToFlowDirection()); } if (ExpressionSearch.Default == null) { ExpressionSearch.Default = new AndroidExpressionSearch(); } IsInitialized = true; Profile.FrameEnd(); }
static void SetupInit(Context activity, Assembly resourceAssembly) { if (!IsInitialized) { // Only need to get this once; it won't change ApplicationContext = activity.ApplicationContext; } #pragma warning disable 618 // Still have to set this up so obsolete code can function Context = activity; #pragma warning restore 618 if (!IsInitialized) { // Only need to do this once ResourceManager.Init(resourceAssembly); } // We want this to be updated when we have a new activity (e.g. on a configuration change) // This could change if the UI mode changes (e.g., if night mode is enabled) Color.SetAccent(GetAccentColor(activity)); _ColorButtonNormalSet = false; if (!IsInitialized) { // Only need to do this once Internals.Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because AndroidPlatformServices needs a current activity to launch URIs from Device.PlatformServices = new AndroidPlatformServices(activity); // use field and not property to avoid exception in getter if (Device.info != null) { ((AndroidDeviceInfo)Device.info).Dispose(); Device.info = null; } // We want this to be updated when we have a new activity (e.g. on a configuration change) // because Device.Info watches for orientation changes and we need a current activity for that Device.Info = new AndroidDeviceInfo(activity); Device.SetFlags(s_flags); var ticker = Ticker.Default as AndroidTicker; if (ticker != null) { ticker.Dispose(); } Ticker.SetDefault(new AndroidTicker()); if (!IsInitialized) { // Only need to do this once Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute) }); } // This could change as a result of a config change, so we need to check it every time int minWidthDp = activity.Resources.Configuration.SmallestScreenWidthDp; Device.SetIdiom(minWidthDp >= TabletCrossover ? TargetIdiom.Tablet : TargetIdiom.Phone); if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1) { Device.SetFlowDirection(activity.Resources.Configuration.LayoutDirection.ToFlowDirection()); } if (ExpressionSearch.Default == null) { ExpressionSearch.Default = new AndroidExpressionSearch(); } IsInitialized = true; }
public static void Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } var accent = (WSolidColorBrush)Windows.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; Color.SetAccent(accent.ToFormsColor()); #if !UWP_16299 Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); #else Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); #endif if (!Windows.UI.Xaml.Application.Current.Resources.ContainsKey("RootContainerStyle")) { Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); } try { Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(new Microsoft.UI.Xaml.Controls.XamlControlsResources()); #if UWP_16299 Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add( new Windows.UI.Xaml.ResourceDictionary { Source = new Uri("ms-appx:///Xamarin.Forms.Platform.UAP/Shell/ShellStyles.xbf") }); #endif } catch { Log.Warning("Resources", "Unable to load WinUI resources. Try adding Xamarin.Forms nuget to UWP project"); } Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); var platformServices = new WindowsPlatformServices(Window.Current.Dispatcher); Device.PlatformServices = platformServices; Device.PlatformInvalidator = platformServices; Device.SetFlags(s_flags); Device.Info = new WindowsDeviceInfo(); switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Desktop": if (Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode == Windows.UI.ViewManagement.UserInteractionMode.Touch) { Device.SetIdiom(TargetIdiom.Tablet); } else { Device.SetIdiom(TargetIdiom.Desktop); } break; case "Windows.Mobile": Device.SetIdiom(TargetIdiom.Phone); break; case "Windows.Xbox": Device.SetIdiom(TargetIdiom.TV); break; default: Device.SetIdiom(TargetIdiom.Unsupported); break; } ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); Registrar.RegisterAll(new[] { typeof(ExportRendererAttribute), typeof(ExportCellAttribute), typeof(ExportImageSourceHandlerAttribute), typeof(ExportFontAttribute) }); IsInitialized = true; s_state = launchActivatedEventArgs.PreviousExecutionState; Platform.UWP.Platform.SubscribeAlertsAndActionSheets(); }
public static void Init( Microsoft.UI.Xaml.LaunchActivatedEventArgs launchActivatedEventArgs, WindowsBasePage mainWindow, IEnumerable <Assembly> rendererAssemblies = null) { if (IsInitialized) { return; } var accent = (WSolidColorBrush)Microsoft.UI.Xaml.Application.Current.Resources["SystemColorControlAccentBrush"]; Color.SetAccent(accent.ToFormsColor()); #if !UWP_16299 Log.Listeners.Add(new DelegateLogListener((c, m) => Debug.WriteLine(LogFormat, c, m))); #else Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); #endif if (!Microsoft.UI.Xaml.Application.Current.Resources.ContainsKey("RootContainerStyle")) { Microsoft.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); } try { Microsoft.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(new Microsoft.UI.Xaml.Controls.XamlControlsResources()); } catch { Log.Warning("Resources", "Unable to load WinUI resources. Try adding Xamarin.Forms nuget to UWP project"); } Device.SetIdiom(TargetIdiom.Tablet); Device.SetFlowDirection(GetFlowDirection()); Device.SetFlags(s_flags); Device.Info = new WindowsDeviceInfo(); switch (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Desktop": if (Windows.UI.ViewManagement.UIViewSettings.GetForCurrentView().UserInteractionMode == Windows.UI.ViewManagement.UserInteractionMode.Touch) { Device.SetIdiom(TargetIdiom.Tablet); } else { Device.SetIdiom(TargetIdiom.Desktop); } break; case "Windows.Mobile": Device.SetIdiom(TargetIdiom.Phone); break; case "Windows.Xbox": Device.SetIdiom(TargetIdiom.TV); break; default: Device.SetIdiom(TargetIdiom.Unsupported); break; } ExpressionSearch.Default = new WindowsExpressionSearch(); Registrar.ExtraAssemblies = rendererAssemblies?.ToArray(); s_state = launchActivatedEventArgs.UWPLaunchActivatedEventArgs.PreviousExecutionState; MainWindow = mainWindow; Xamarin.Forms.Forms.InitDispatcher(mainWindow.DispatcherQueue); mainWindow.LoadApplication(mainWindow.CreateApplication()); mainWindow.Activate(); }