当窗口最大化时,控件应保持什么属性不变 [英] What property should the control have to stay the same when window is Maximized

查看:139
本文介绍了当窗口最大化时,控件应保持什么属性不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我按下WPF应用程序上的最大化"按钮时,其中的所有控件都会展开并破坏我已经为它们设置的位置.我应该在每个控件的某个位置设置属性吗?

谢谢您的帮助.

When I press the Maximize button on my WPF app, all the controls therein expand and disrupt the positions I already had for them. Should I be setting a property somewhere on each control?

Thank you for your help.

推荐答案

否.相反,您应该按照尺寸允许的方式设计窗口布局.

避免任何手动定位.实际上,如果您的窗口是可调整大小的,则切勿手动放置单个控件,即使假定窗口具有固定大小,也不要避免放置它.布局应基于Grid,DockPanels等,并使用Padding,Margin和相关属性.要使不同窗口具有统一的外观,请使用ResourceDictionary.

您可能需要从头开始学习FrameWorkElements以及布局模型.从这里开始:
http://msdn.microsoft.com/en-us/library/ms745058.aspx [ ^ ],
http://wpftutorial.net/LayoutProperties.html [ http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.aspx#inheritanceContinued [ ^ ],
http://msdn.microsoft.com/en-us/library/ms754152.aspx [ ^ ].

有关使用ResourceDictionaries的信息,请参见:
http://msdn.microsoft.com/en-us/library/ms750613.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/aa350178.aspx [ ^ ],
http: //blogs.msdn.com/b/wpfsldesigner/archive/2010/06/03/creating-and-using-resource-dictionaries-in-wpf-and-silverlight.aspx [在WPF中使用资源字典 [
No. Instead, you should design the window layouts the size-tolerant way.

Avoid any manual positioning. Actually, if your window is resizeable, never position a single control manually, and avoid it even if a window is supposed to have a fixed size. The layout should be based on the Grids, DockPanels, etc., using Padding, Margin and related properties. To make a uniform look of different windows, use ResourceDictionary.

You might need to learn FrameWorkElements from scratch, as well as the layout model. Start here:
http://msdn.microsoft.com/en-us/library/ms745058.aspx[^],
http://wpftutorial.net/LayoutProperties.html[^],
http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.aspx#inheritanceContinued[^],
http://msdn.microsoft.com/en-us/library/ms754152.aspx[^].

On using ResourceDictionaries, please see:
http://msdn.microsoft.com/en-us/library/ms750613.aspx[^],
http://msdn.microsoft.com/en-us/library/aa350178.aspx[^],
http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/03/creating-and-consuming-resource-dictionaries-in-wpf-and-silverlight.aspx[^]

This CodeProject article can also be useful:
Using a Resource Dictionary in WPF[^].

—SA


这篇关于当窗口最大化时,控件应保持什么属性不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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