Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

I have a User Control Win Form hosted in WPF Window.At higher screen resolution size of Win host is less than that of WPF Window.(WPF Window size grows)
Please let me know if there is any way to make two of them in Sync in all resolutions.
Posted
Updated 14-Jul-15 9:39am
v2
Comments
Sergey Alexandrovich Kryukov 14-Jul-15 15:26pm    
May I ask you why you could not have only WFP, without Forms, or only Forms, without WPF?
—SA
Sreepada1005 14-Jul-15 15:30pm    
Its an existing application (I cannot change this to Form only/WPF only App).Is there any way to solve this issue please?
Sergey Alexandrovich Kryukov 14-Jul-15 15:39pm    
Please see my answer.
—SA

1 solution

What you call "resolution" is not resolution; this is simply the screen size in pixel. Resolution is very different concept, it refers to the ability of some system to resolve certain number of lines per mm/inch as separate lines; it's only in jargon use screen size is called "resolution"; we should avoid it.

The problem you described simply does not exist. You should not use manual sizes of any control. On Forms side, you can use Dock and Padding properties for all controls, with the Dock values other than System.Windows.Forms.DockStyle.None, it will auto-size all layout:
https://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.forms.dockstyle%28v=vs.110%29.aspx[^].

On WPF side, there are many layout features where the size of the container UI element is defined by the size of content, and the size of content is defined by the size of the container. Just one example is using the value "Auto" or "*" for ColumnWidth or RowHeight in row or column definitions use for the System.Windows.Controls.Grid:
https://msdn.microsoft.com/en-us/library/system.windows.controls.grid%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.controls.grid.rowdefinitions%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.windows.controls.grid.columndefinitions%28v=vs.110%29.aspx[^].

Another example is System.Windows.Controls.DockPanel:
https://msdn.microsoft.com/en-us/library/system.windows.controls.dockpanel%28v=vs.110%29.aspx[^].

You also need to understand how the Window sizing is defined: https://msdn.microsoft.com/en-us/library/system.windows.window.sizetocontent%28v=vs.110%29.aspx[^].

For mode detail on background, read on WPF Layout Model:
https://msdn.microsoft.com/en-us/library/vstudio/ms745058%28v=vs.100%29.aspx[^],
http://www.wpftutorial.net/LayoutProperties.html[^].

Design proper layout, and you will never face the problem you described.

—SA
 
Share this answer
 
v2
Comments
Sreepada1005 15-Jul-15 15:37pm    
Setting proper layout solves the problem.I actually misunderstood the behavior.
Thanks!
Sergey Alexandrovich Kryukov 15-Jul-15 15:41pm    
You are very welcome.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900