I move the use of the AppCallbacks class from the App.cs class to the existing MainPage.<\/li>\n<\/ul>\n <\/p>\n
The next steps are easy : I create a new Window, add a frame in it and navigate to the MainPage. I use exactly the same snippet as before and I only have to register an event handler to the activation of the created Window to be able to initialize Unity then. I also store the main view’s Id for further use.<\/p>\n
\r\nprivate async Task CreateNewHoloWindowAsync()\r\n{\r\n var appViewId = MainAppViewId = ApplicationView.GetForCurrentView().Id;\r\n \r\n var _newCoreAppView = CoreApplication.CreateNewView();\r\n \r\n await _newCoreAppView.Dispatcher\r\n .RunAsync(CoreDispatcherPriority.Low,\r\n async () =>\r\n {\r\n var frame = new Frame();\r\n Window.Current.Content = frame;\r\n frame.Navigate(typeof(MainPage));\r\n \r\n var res = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(\r\n ApplicationView.GetForCurrentView().Id,\r\n ViewSizePreference.Default, appViewId,\r\n ViewSizePreference.Default);\r\n \r\n _newCoreAppView.CoreWindow.Activated += WindowActivated;\r\n \r\n _newCoreAppView.CoreWindow.Activate();\r\n });\r\n}\r\n \r\nprivate void WindowActivated(object sender, WindowActivatedEventArgs e)\r\n{\r\n if (e.WindowActivationState == CoreWindowActivationState.CodeActivated\r\n || e.WindowActivationState == CoreWindowActivationState.PointerActivated)\r\n {\r\n AppCallbacks.Instance.SetInitialViewActive();\r\n \/\/ Only need to mark initial activation once so unregister ourself\r\n CoreWindow coreWindowSender = sender as CoreWindow;\r\n coreWindowSender.Activated -= WindowActivated;\r\n }\r\n}\r\n\r\n<\/pre>\nGoing back to the 2D View<\/h4>\n
To go back to the 2D XAML view, you have to use the ApplicationViewSwitcher class and ask it to go switch back to the main Window.<\/p>\n
I provide my Unity’s code an Action (GoBackToEarth.CloseThisHolographicView) it can call when needed.<\/p>\n
\r\n\/\/ let's capture the dispatcher of the current view\r\nvar dispatcher = Dispatcher;\r\n \r\nGoBackToEarth.CloseThisHolographicView = () =>\r\n{\r\n \/\/ be sure to be on the Window's Dispatcher\r\n dispatcher.RunIdleAsync(async _ =>\r\n {\r\n \/\/ go back to the main Window\r\n await ApplicationViewSwitcher.SwitchAsync(StartupPage.MainAppViewId);\r\n \r\n \/\/ we close the 3D holographic Window\r\n Window.Current.Close();\r\n });\r\n};\r\n\r\n<\/pre>\nHappy coding !<\/p>\n","protected":false},"excerpt":{"rendered":"
In this blog post I will show you how to create a 2D #XAML app which will be able to display a 3D view (holograms) and then how to go back to the 2D view…<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[54,49,5],"tags":[19,55,14,15,20,40,24],"_links":{"self":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1573"}],"collection":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/comments?post=1573"}],"version-history":[{"count":13,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1573\/revisions"}],"predecessor-version":[{"id":1586,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1573\/revisions\/1586"}],"wp:attachment":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media?parent=1573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/categories?post=1573"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/tags?post=1573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}