I have a UWP project with two monitors that I want to use to open a new window on a secondary monitor. The application includes three parts:
- Open Main Page on first monitor
- Create new page
- Open on secondary monitor
I wrote the first and second parts correctly, but I can't find a solution for the third part.
Please help me with moving the window to another monitor.
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
//called creat new page function
NewWindow();
}
private async void NewWindow()
{
var myview = CoreApplication.CreateNewView();
int newid = 0;
await myview.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Frame newframe = new Frame();
newframe.Navigate(typeof(Newpage), null);
Window.Current.Content = newframe;
Window.Current.Activate();
ApplicationView.GetForCurrentView().Title = "Z";
newid = ApplicationView.GetForCurrentView().Id;
});
await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newid, ViewSizePreference.UseMinimum);
}
}