Reputation: 53
With a grid, i can say that i want one element to take up 3/4 of the page and one to take up 1/3 of the page by using width = "3*" and width = "1*"
Is it possible to do the same with Stackpanels? Or is the only way to do it by placing the stackpanels inside a grid?
Upvotes: 0
Views: 622
Reputation: 69959
In the .NET Framework, there are a number of different Panel
classes. Some of them like the Grid
and DockPanel
provide resizing capabilities that resize the Panel
children, while others don't. Generally, the ones that provide this functionality have a cost in terms of CPU and/or RAM.
Therefore, when requiring a Panel
for simple layout purposes, these Panel
types should be avoided and a simple StackPanel
should be used instead. Other times, we require this extra functionality and so we should use one of these more expensive Panel
s.
Please see the Panels Overview page on MSDN for a much fuller description of the .NET Panel
s.
So, to actually answer your question(s), no, a StackPanel
cannot use similar sizing capabilities as the Grid
and you can't do what you want even if you place StackPanel
s inside a Grid
because although the Grid
's cells may change size when the parent is resized, the StackPanel
s contained within will not.
Upvotes: 1