Reputation: 1092
What I want to do (I actually don't know if it's possible) is to set the height of a given row according to its content:
< Grid.RowDefinitions> < RowDefinition Height="{Binding ElementName=aaa, Path=Height" /> < RowDefinition Height="*" /> < /Grid.RowDefinitions>
Assume that aaa is put into the row of the Grid.
Please note: I want my row to keep the height set at the very beginning.
Is that possible at all?
Cheers!
Upvotes: 2
Views: 2328
Reputation: 1217
<RowDefinition Height="Auto" />
should do what you want.
EDIT
What you could do is add an handler to your content's SizeChanged event. In that handler, set the grid's appropriate RowDefinition's height to the ActualHeight of the content and remove the handler:
grid.RowDefinitions[x].Height = new GridLength(((FrameworkElement)sender).ActualHeight, GridUnitType.Pixel);
content.SizeChanged -= content_SizeChanged;
I haven't tested it, but it should give you a good start. EDIT tested, it works. Maybe there's a better way to do it, but that's one way.
Upvotes: 2