Click here to Skip to main content
15,890,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

1 solution

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
 
Share this answer
 
v3

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