WPF: comment mettre le feu à un EventTrigger (ou Animation) lors de la liaison des changements?

Nous avons une animation simple qui s'exécute quand un ToggleButton est activée et désactivée (développe un ListView de la hauteur et s'effondre alors une liste de hauteur). Comment avez-vous feu la EventTrigger (ou Animation) pour les <Storyboard x:Key="CommentsCollapse"> lorsque le DataContext de Liaison des changements dans la x:Name="DetailsGrid" Grille dans le code XAML suivant?

En d'autres termes, chaque fois que la Liaison des changements pour le "DetailsGrid", nous voulons que le "CommentsCollapse" table de montage séquentiel pour être déclenchée pour assurer la ListView est retourné à son état effondré.

<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="400">
<Page.Resources>
<Storyboard x:Key="CommentsExpand">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="CommentsListView"
Storyboard.TargetProperty="(FrameworkElement.Height)">
<SplineDoubleKeyFrame KeyTime="00:00:00.200" Value="300"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="CommentsCollapse">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="CommentsListView"
Storyboard.TargetProperty="(FrameworkElement.Height)">
<SplineDoubleKeyFrame KeyTime="00:00:00.200" Value="75"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
<Page.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked" SourceName="CommentsToggleButton">
<BeginStoryboard Storyboard="{StaticResource CommentsExpand}"/>
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked" SourceName="CommentsToggleButton">
<BeginStoryboard Storyboard="{StaticResource CommentsCollapse}"/>
</EventTrigger>
</Page.Triggers>
<Grid DataContext="{Binding Path=CurrentTask.Workflow.Invoice}" x:Name="DetailsGrid">
<StackPanel Orientation="Horizontal">
<Canvas Width="428">
<GroupBox Width="422" Margin="5,0,0,0">
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<ToggleButton
x:Name="CommentsToggleButton"
Width="20"
Height="10"
Margin="5,0,0,0">
<ToggleButton.Content>
<Rectangle
Width="5"
Height="5"
Fill="Red"/>
</ToggleButton.Content>
</ToggleButton>
<TextBlock Foreground="Blue" Text="Comments"/>
</StackPanel>
</GroupBox.Header>
<ListView
x:Name="CommentsListView"
Height="75"
ItemsSource="{Binding Path=Comments}">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=Date}" Header="Date"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Name}" Header="User"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Description}" Header="Comment"/>
</GridView>
</ListView.View>
</ListView>
</GroupBox>
</Canvas>
</StackPanel>
</Grid>
</Page>
InformationsquelleAutor Metro Smurf | 2009-11-19