I have a control which contains 2 rows (header and content). The content has a ScaleY transform on it when the pointer enters or exists, but it seems the row which has height Auto does not collapse the height when the content is scaled to 0.
<Page
x:Class="ScaleTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ScaleTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<local:TestControl VerticalAlignment="Bottom"/>
</Grid>
<Style TargetType="local:TestControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:TestControl">
<Grid VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="DisplayStates">
<VisualState x:Name="Minimized">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="contentTransForm"
Storyboard.TargetProperty="ScaleY"
Duration="0:0:0.2"
To="0"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Maximized">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="contentTransForm"
Storyboard.TargetProperty="ScaleY"
Duration="0:0:0.2"
To="1"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid Background="Red">
<TextBlock Text="Header"/>
</Grid>
<Grid Grid.Row="1" Background="Orange">
<Grid.RenderTransform>
<CompositeTransform x:Name="contentTransForm" ScaleY="0" ScaleX="1"/>
</Grid.RenderTransform>
<TextBlock Text="Content"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I made a small sample app to show the problem. sample
Why the grid is not updating.
Thanks guys,
I actually solved it by implementing a LayoutTansformer from the wpf toolkit and using a mediator it and the transformer. It gives a nice smooth animation without staying up and then suddenly collapsing.
the LayoutTransformer:
the Mediator:
The TestControl: