Я использую .net 4, vs2010 и создал пользовательский элемент управления, который должен начинаться свернутым и прозрачным (непрозрачность 0) и становиться видимым и непрозрачным в ответ на нажатие кнопки.
<UserControl x:Class="Ihi.LeadRetrieval.Client.Views.HelpView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid x:Name="HelpGrid" Visibility="Collapsed" Opacity="0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="HelpStateGroup">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.5">
<VisualTransition.GeneratedEasingFunction>
<CircleEase EasingMode="EaseInOut"/>
</VisualTransition.GeneratedEasingFunction>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="HelpOpen">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HelpGrid">
<EasingDoubleKeyFrame KeyTime="0" Value="0.95"/>
</DoubleAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="HelpGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="HelpClosed">
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border Background="#00427A" CornerRadius="3">
<DockPanel Margin="5">
<ContentPresenter DockPanel.Dock="Bottom" Margin="12,10,0,0" Content="{Binding Path=Detail}" Style="{StaticResource HelpText}"/>
<Label Style="{StaticResource HelpHeaderText}" Content="{Binding Path=Header}" DockPanel.Dock="Left" MaxHeight="50"/>
<Button x:Name="CloseHelpButton" Style="{StaticResource HelpButtonStyle}" Content="X" HorizontalAlignment="Right" VerticalAlignment="Top" DockPanel.Dock="Right" MaxHeight="50">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ei:GoToStateAction x:Name="CloseAction" StateName="HelpClosed"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</DockPanel>
</Border>
</Grid>
Однако, когда я нацеливаюсь на этот элемент управления из родительского пользовательского элемента управления и запускаю визуальное состояние HelpOpen, я замечаю, что после завершения анимации элемент управления справки появляется резко - он не исчезает, как ожидалось.
<view:HelpView x:Name="helpView" />
<Button x:Name="ButtonOpen" Margin="0,0,25,0" VerticalAlignment="Top" Content="Open">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ei:GoToStateAction TargetObject="{Binding ElementName=helpView}" StateName="HelpOpen"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
Я считаю, что это потому, что элемент справки становится видимым только в конце анимации и, следовательно, переход увеличения непрозрачности не отображается.
Есть ли способ указать, что видимостьсвойство будет установлено видимым, прежде чем значение непрозрачности будет скорректировано?