1.通过绑定的属性值变化,动态改变界面的显示,比如绑定了IsExpanded,当为true,grid高度变成600,反之,grid高度变成320.
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<DataTrigger Binding="{Binding IsExpanded}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard >
<DoubleAnimation From="320"
To="600"
Duration="0:0:1"
Storyboard.TargetProperty="Height"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="600"
To="320"
Duration="0:0:1"
Storyboard.TargetProperty="Height"></DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions> </DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>