我有一个带有两个显示器的 UWP 项目,我想用它在辅助显示器上打开一个新窗口。申请包括三个部分:
我正确地写了第一和第二部分,但我找不到第三部分的解决方案。
请帮我将窗口移动到另一台显示器。
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);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一个有两个页面的Windows应用程序(UWP),我希望在页面之间传递参数的最佳实践.
这是我的情景:
我们有两个页面,每个页面都打开并保留在屏幕中间,每个页面上都有一个按钮,当我们点击它时,它会将消息发送到另一个页面.
我也想连续不断地传递信息.
在Page1.cs中:
Page2 page2;
public Page1()
{
this.InitializeComponent();
CreatPage2();
}
// creat page 2
private async void CreatPage2()
{
var NewWindow = CoreApplication.CreateNewView();
int NewWindowid = 0;
await NewWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
{
Frame newframe = new Frame();
newframe.Navigate(typeof(Page2), this);
Window.Current.Content = newframe;
Window.Current.Activate();
ApplicationView.GetForCurrentView().Title = "page2";
NewWindowid = ApplicationView.GetForCurrentView().Id;
});
await Windows.UI.ViewManagement.ApplicationViewSwitcher.TryShowAsStandaloneAsync(NewWindowid);
}
//Button
private void ChangeP2_Click(object sender, RoutedEventArgs e)
{
// send a message to the texblock in the …Run Code Online (Sandbox Code Playgroud)