So, basically, one of my feature ideas would need a secondary window (if you open Windows Mail and then click on "Open in a new Window, you can see what I mean).
For that you have two choices: ProjectionView (which is intended for non-interactive displays) and a completely new View. The official documentation by Microsoft states that this is the only way to do this:
private async void Button_Click(object sender, RoutedEventArgs e)
{
CoreApplicationView newView = CoreApplication.CreateNewView();
int newViewId = 0;
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Frame frame = new Frame();
frame.Navigate(typeof(SecondaryPage), null);
Window.Current.Content = frame;
Window.Current.Activate();
newViewId = ApplicationView.GetForCurrentView().Id;
});
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
}
This works just fine. However, a problem arises when I then try to wire Prism/Unity into this new Window/Frame - since the new Window lives in its own thread, it will run into an exception if I simply try to let Prism autowire things (cross-thread data access violation).
Does anyone have an idea on how to proceed? Especially since the data to display comes from an SQLite store and, IIRC, SQLite isn't exactly thread-safe either.
edit: Callstack follows below:
Eine Schnittstelle, die für einen anderen Thread marshalled war,
wurde von der Anwendung aufgerufen.
(Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
at Windows.UI.Xaml.DependencyObject.GetValue(DependencyProperty dp)
at Prism.Windows.Navigation.FrameFacadeAdapter.GetValue(DependencyProperty dependencyProperty)
at Prism.Windows.AppModel.SessionStateService.GetSessionStateForFrame(IFrameFacade frame)
at Prism.Windows.PrismApplication.<>c__DisplayClass54_0.<InitializeFrameAsync>b__0(IFrameFacade frame)
at Prism.Windows.Mvvm.SessionStateAwarePage.OnNavigatedTo(NavigationEventArgs navigationEventArgs)
User contributions licensed under CC BY-SA 3.0