11

I'm used to the GUI frameworks in Java as well as the QT GUI framework, and I'm used to the various layout managers. It doesn't seem that C# has any layout managers built in, or am I missing something?

2 Year Later Edit

I just want to point out to any readers of this question that in hind-sight, my question was misplaced. With proper anchoring and docking of child controls, having a need for the layout managers of Java and QT4 is nearly non-existent.

Community
  • 1
  • 1
Anthony
  • 9,451
  • 9
  • 45
  • 72

5 Answers5

8

WPF does have layout managers, see:

http://msdn.microsoft.com/en-us/library/ms745058.aspx

If you're coming from a Java background, then the section "Panel Elements and Custom Layout Behaviors" will be of particular interest.

Tim Lloyd
  • 37,954
  • 10
  • 100
  • 130
  • 1
    There are a couple problems here: To get the System.Windows.Controls namespace you need to add a reference to PresentationFramework under .NET but the problem with that is that it causes a namespace clash between objects like System.Windows.Forms.Panel and System.Windows.Controls.Panel. What the heck is going on here and why is this so hard? – fIwJlxSzApHEZIl Dec 11 '12 at 18:41
  • I gave up and just went with System.Windows.Forms.FlowLayoutPanel – fIwJlxSzApHEZIl Dec 11 '12 at 19:16
3

Both WPF and Windows Forms provide layout capabilities (WPF is just much better at it).

You can achieve moderately complex layouts in Windows Forms too by utilizing the Dock and Anchor properties of controls. Personally I learned what can be achieved and how through Petzold's book on WinForms. If you don't have access to that book, read this short article.

Jon
  • 428,835
  • 81
  • 738
  • 806
1

chibacity is right, WPF is loaded with layout managers, all of them are very good.

However if you're going down the WinForms route, you're stuck with TableLayoutPanel, FlowLayoutPanel and SplitContainer. As well as the usual manual Panel and GroupBox controls.

Tom
  • 3,354
  • 1
  • 22
  • 25
0

No, you are not missing anything.

.NET does not have built in layout managers for Winforms/Webforms/Console development.

Probably because Visual Studio has good designers, obviating the need.

WPF and Silverlight (both using XAML) do have them, though they are not exactly the same as the Java ones.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • 14
    A good designer does *not* obviate the need for layout managers. – Matti Virkkunen Oct 30 '11 at 22:34
  • 1
    I would suggest that not having to target as diverse a set of consumer platforms makes static layout a more reasonable approach. If Java were only interested in static layout, I imagine the GUI designers would be much simpler. – Dilum Ranatunga Mar 16 '12 at 20:04
0

WPF and Silverlight have different "Panels" that work similar to the layout managers in other languages.

Master Morality
  • 5,837
  • 6
  • 31
  • 43