混合winform和WPF控件的表单在两台显示器之间移动时会损坏吗? [英] Form with mixed winform and WPF controls is corrupted when moved between two monitors?

查看:127
本文介绍了混合winform和WPF控件的表单在两台显示器之间移动时会损坏吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我有一个使用WPF和ElementHost控件来托管WinForms 用户控件的表单。我遇到的问题是当我在具有不同分辨率和缩放元素的两个显示器之间移动表单时,元素主机控件不会调整大小正确并在其边框周围显示一些
黑色空间。


任何想法如何解决这个问题?





谢谢


  ;




解决方案



嗨   开发人员生活,



>>我有一个正在使用的表单WPF和ElementHost控件来托管WinForms用户控件。我遇到的问题是当我在具有不同分辨率的两个显示器之间移动表单并缩放元素时
主机控件没有正确调整大小并在其边框周围显示一些黑色空间。




很难指出具体原因。可能是由具有不同DPI的多监视器引起的。 
$


您可以尝试以下方法在正确的目标DPI上呈现WinForms和WPF内容。  
$


  1)在条目汇编中的命名空间声明上方设置[assembly:DisableDpiAwareness]属性



 xmlns:asmv3 =" urn:schemas-microsoft-com:asm.v3" 

  2)您可以在项目中添加app.manifest文件并添加以下内容:

< asmv3:windowsSettings 
xmlns =" http://schemas.microsoft.com/SMI/2005/WindowsSettings">
< dpiAware> true / PM< / dpiAware>
< / asmv3:windowsSettings>




以下链接供您参考。



混合WPF和winforms项目DPI意识
$


WinForms Scaling at Large DPI Settings-Is它甚至可能?




注意:此回复包含参考第三方万维网站点。 Microsoft提供此信息是为了方便您。 Microsoft不控制这些网站,也未测试在这些网站上找到的任何软件或信息;因此,
Microsoft不能就其中发现的任何软件或信息的质量,安全性或适用性做出任何陈述。使用互联网上的任何软件都存在固有的危险,微软提醒您在从互联网上检索任何软件之前确保您完全了解风险。 





最好的问候,



Yong Lu








Hello,

I have a form that is using WPF and ElementHost control to host a WinForms user control. The issue I have is when I move the form between two monitors with different resolution and scaling the element host control does not resize correct and shows some black space around its border.

any ideas how to solve this?


Thanks

 


解决方案


Hi   Developer life,

>>I have a form that is using WPF and ElementHost control to host a WinForms user control. The issue I have is when I move the form between two monitors with different resolution and scaling the element host control does not resize correct and shows some black space around its border.

It is difficult to point out the specific reasons. Maybe it cause by the multi monitor with the different DPIs. 

You can try the following methods to render your WinForms and WPF content both at the right target DPI. 

 1) set [assembly: DisableDpiAwareness] attribute above the namespace declaration in your entry assembly

        xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"

 2) you can add an app.manifest file in your project and add the following :

 <asmv3:windowsSettings
 xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
       <dpiAware>true/PM</dpiAware> 
 </asmv3:windowsSettings>


The following links for your reference.

Mixed WPF and winforms project DPI awareness

WinForms Scaling at Large DPI Settings–Is It Even Possible?


Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet. 


Best Regards,

Yong Lu


这篇关于混合winform和WPF控件的表单在两台显示器之间移动时会损坏吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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