I have collection of errors on the screen, one line per one error. User can close any error message by clicking the button on that row. Code example:
<UserControl>
<ItemsControl ItemsSource="{Binding Errors}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid x:Name="grid" Height="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding ErrorText}"/>
<Button Grid.Column="1" Width="16" Height="16" Content="Close" Command="{Binding DataContext.RemoveErrorCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}" CommandParameter="{Binding CurrentError}">
<Button.Triggers>
<EventTrigger RoutedEvent="ButtonBase.Click">
<BeginStoryboard>
<Storyboard TargetProperty="Height" TargetName="grid">
<DoubleAnimation To="0" Duration="0:0:0.35"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</UserControl>
What's the problem: as you can see, i added trigger with storyboard to make it clear, i want to smoothly hide the message, and only after to close it. So it will be, first storyboard, then executing the command. How can it be achieved? As less codebehind as possible, please.