在特定屏幕点加载WPF应用程序 [英] Load WPF app in a specific screen point

查看:102
本文介绍了在特定屏幕点加载WPF应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在特定的屏幕点加载WPF?我尝试了下一个代码,我搜索了其他资源,比如WorkingArea或WindowStartupLocation但是我做不到。



 private void Application_Startup( object sender,StartupEventArgs e)
{
base.OnStartup(e);
MainWindow m = new MainWindow();
点数= m.PointToScreen(
new Point(320,120)); double dpiX =
96.0 * source.CompositionTarget.TransformToDevice.M11;
double dpiY =
96.0 * source.CompositionTarget.TransformToDevice.M22;

m.Left = point.X * 96.0 / dpiX; ;
m.Top = point.Y * 96.0 / dpiX; ; * /& lt; / pre& gt; < / pre >
m.Show();
}



目标是加载不同的WPF应用程序并用它们填充屏幕。有更好的方法吗?

请帮助:)

解决方案

这里: https://msdn.microsoft.com/en-us/library/system.windows。 window.windowstartuplocation%28v = vs.110%29.aspx [ ^ ]。



你做的事情没什么意义。如果您希望多个应用程序在屏幕上自行排列主窗口,则首先需要查询屏幕大小。此外,您还需要照顾尺寸。最后,您的应用程序不会了解彼此;这样合理吗?你想让那个预定义的窗口位置独立于其他窗口吗?也许,如果你安排一些固定的应用程序,最好将它们集成在一起?



-SA

How can I load a WPF in a specific screen point? I tried next code and I searched about other resources like the WorkingArea or WindowStartupLocation but I could not do it.

private void Application_Startup(object sender, StartupEventArgs e)
        {
                     base.OnStartup(e);
MainWindow m = new MainWindow();
Point point = m.PointToScreen(
                            new Point(320, 120));double dpiX =
               96.0 * source.CompositionTarget.TransformToDevice.M11;
           double dpiY =
               96.0 * source.CompositionTarget.TransformToDevice.M22;

           m.Left = point.X * 96.0 / dpiX; ;
           m.Top = point.Y * 96.0 / dpiX; ;*/&lt;/pre&gt;</pre>
   m.Show();
}


The goal is to load different WPF apps and fill the screen with them. Is there a better way to do this?
Help please :)

解决方案

Here: https://msdn.microsoft.com/en-us/library/system.windows.window.windowstartuplocation%28v=vs.110%29.aspx[^].

What you are doing makes little sense. If you want several applications to self-arrange their main windows on the screen, you first need to inquire the screen size. Also, you need to take care of sizes as well. Finally, your applications don't "know" about each other; is that reasonable? Do you want to have that predefined window location independent from other ones? Maybe, if you arrange some fixed set of applications, it would be better to integrate them all in one?

—SA


这篇关于在特定屏幕点加载WPF应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆