The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
How to switch from 2D Xaml view to 3D holographic view (Directx)
Hello,
I've been able to get both xaml UWP apps and the 3D holographic sample running on the emulator but am Having trouble starting out with a xaml view and then switching to a holographic view. The docs say that this is possible and give some Classes (https://developer.microsoft.com/en-us/windows/holographic/app_model) to use but I haven't been successful yet. Is there an example of this somewhere?
Thank you,
Kyle
Best Answer
-
NajaDojo ✭
This is pretty easy to put together with the Visual Studio templates. Create a new Holographic DirectX 11 App. Then create another Xaml project (Blank App is enough). Copy contents of the 3D app project into the Xaml project. You'll need to actually combine the pch.h and remove the main() function from the AppView.cpp. Add a button to the Xaml app and make the handler something like:
void HolographicDxXaml::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto newView = CoreApplication::CreateNewView(ref new HolographicDX::AppViewSource());newView->Dispatcher->RunAsync( CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() { auto viewId = ApplicationView::GetForCurrentView()->Id; CoreWindow::GetForCurrentThread()->Activate(); CoreApplication::MainView->Dispatcher->RunAsync( CoreDispatcherPriority::Normal, ref new DispatchedHandler([viewId]() { auto asyncAction = ApplicationViewSwitcher::SwitchAsync( viewId, ApplicationView::GetForCurrentView()->Id); })); }));
}
That's just example code you'll want to actually manage the newView and viewId so you could switch back and forth. https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/MultipleViews has some better practices.
6
Answers
This is pretty easy to put together with the Visual Studio templates. Create a new Holographic DirectX 11 App. Then create another Xaml project (Blank App is enough). Copy contents of the 3D app project into the Xaml project. You'll need to actually combine the pch.h and remove the main() function from the AppView.cpp. Add a button to the Xaml app and make the handler something like:
void HolographicDxXaml::MainPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
auto newView = CoreApplication::CreateNewView(ref new HolographicDX::AppViewSource());
}
That's just example code you'll want to actually manage the newView and viewId so you could switch back and forth. https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/MultipleViews has some better practices.
Ahhhh was so simple. Thank you very much. Very helpful.