UPDATED I have an obtuse requirement I'm trying to fulfill working with existing elements and I'm at a point I could really use another pair of eyes.
For quicker explanation, some pseudo;
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid/>
<Grid Grid.Row="1"/>
<Grid Grid.Row="2"/>
<Grid Grid.Row="3" Visibility="Collapsed">
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="1">
<ItemsControl/>
</ScrollViewer/>
</Grid>
</Grid>
So what we have here is a parent Grid
with a child Grid
whose visibility gets toggled. Currently the parent's row has an Auto height set so when the child disappears, the row collapses.
Originally, there was just a MaxHeight
set on the child which invoked the ScrollViewer
scrollbar just fine when it's made visible. Except I need to ditch the MaxHeight
and let it take up all the space it has available/needs and at the same time invoke the scrollbar on the ScrollViewer
when the size changes. I should also mention I'm trying to accomplish this entire in XAML with no code behind if I can.
I tried rigging an EventTrigger
to SizeChanged
and also tried Loaded
and let it do a CallMethodAction
to perform UpdateLayout
hoping it would re-draw/measure the ScrollViewer
to invoke the scrollbar if it's required. However no joy...
Something like this attached to the ScrollViewer
;
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<ei:CallMethodAction MethodName="UpdateLayout"/>
</i:EventTrigger>
</i:Interaction.Triggers>
I'm hoping someone who's got more sleep than I have can offer some insight to my folly or what I'm forgetting? Seems like something like this should work.
All I need it to do, is still respect the Visibility
change and allow the parent's row to collapse, but still invoke a scrollbar when it's Visible and it's required. Any tricks?
PS - I'm also trying InvalidateArrange & InvalidateMeasure with no luck, am I perhaps using CallMethodAction incorrectly in this scenario?
Setting
VerticalAlignment="Top"
and noHeight
(orHeight="*"
) on the second RowDefinition in the outer Grid should work: