1.通过绑定的属性值变化,动态改变界面的显示,比如绑定了IsExpanded,当为true,grid高度变成600,反之,grid高度变成320.
1 <Grid.Style> 2 <Style TargetType="Grid"> 3 <Style.Triggers> 4 <DataTrigger Binding="{Binding IsExpanded}" Value="true"> 5 <DataTrigger.EnterActions> 6 <BeginStoryboard> 7 <Storyboard > 8 <DoubleAnimation From="320" 9 To="600" 10 Duration="0:0:1" 11 Storyboard.TargetProperty="Height"></DoubleAnimation> 12 </Storyboard> 13 </BeginStoryboard> 14 </DataTrigger.EnterActions> 15 <DataTrigger.ExitActions> 16 <BeginStoryboard> 17 <Storyboard> 18 <DoubleAnimation From="600" 19 To="320" 20 Duration="0:0:1" 21 Storyboard.TargetProperty="Height"></DoubleAnimation> 22 </Storyboard> 23 </BeginStoryboard> 24 </DataTrigger.ExitActions> 25 26 </DataTrigger> 27 </Style.Triggers> 28 </Style> 29 </Grid.Style>