我正在尝试Show multiple views for an app for Prism Library UWP。
我为System.NullReferenceException
得到了frame.Navigate(typeof(ScreenCapture));
,如下所示:
async void ExecuteNewWindow()
{
CoreApplicationView newView = CoreApplication.CreateNewView();
int newViewId = 0;
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Frame frame = new Frame();
frame.Navigate(typeof(ScreenCapture));
Window.Current.Content = frame;
// You have to activate the window in order to show it later.
Window.Current.Activate();
newViewId = ApplicationView.GetForCurrentView().Id;
});
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
}
如何在uwp的Prism库中实现多视图。
答案 0 :(得分:1)
您的项目是Xamarin.Forms,但是var arr = ['messi', 'mo salah'];
arr = arr.where( (name) => name != 'messi' ).toList();
// results
// arr = ['mo salah'];
的参数是uwp页面类型。我检查了您的代码,frame.Navigate(typeof(ScreenCapture));
是表单ScreenCapture
。根据您的要求,您可以使用Dependency service来调用ContentPage
并将ExecuteNewWindow
放入UWP项目中。
界面
ExecuteNewWindow
实施
public interface INewPageService
{
void CreateNewPage();
}
用法
[assembly: Dependency(typeof(INewPageService))]
namespace BlankApp1.UWP
{
public class INewPageServiceImplement : INewPageService
{
public async void CreateNewPage()
{
CoreApplicationView newView = CoreApplication.CreateNewView();
int newViewId = 0;
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Frame frame = new Frame();
frame.Navigate(typeof(NewPage)); // uwp page
Window.Current.Content = frame;
// You have to activate the window in order to show it later.
Window.Current.Activate();
newViewId = ApplicationView.GetForCurrentView().Id;
});
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
}
}
}
请不要忘记在uwp app.xaml.cs文件中注册它。
DependencyService.Get<INewPageService>(DependencyFetchTarget.NewInstance).CreateNewPage();