I have a Button containing a Grid inside:
<Button>
<Grid Name="grid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Name="txt0" Grid.Row="0" Text="Text0"/>
<TextBlock Name="txt1" Grid.Row="1" Text="Text1"/>
</Grid>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="grid"
Storyboard.TargetProperty="Height"
From="{Binding ElementName=grid, Path=ActualHeight}"
To="{Binding ElementName=txt0, Path=ActualHeight}"
Duration="0:0:1"
FillBehavior="HoldEnd"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
</Button>
When Button is clicked, Grid should be collapsed to display only the text in the first row. And this part works correctly. The strange behaviour happens when I click the collapsed Button again: it expands back to its initial size (two rows are visible), and then collapses to one-row height again. It seems like ActualHeight of the Grid remains unchanged during the animation and after the animation is finished.
So I have two questions:
1) Why is ActualHeight of the Grid not changed, although visually Grid's size is changed.
2) I can achieve desired behaviour if I set Height="*" for the second row. Why in such case Grid's ActualHeight is changed?
Any information would be appreciated.