Я пытаюсь добавить какую-то анимацию к элементам, когда они добавляются в ListBox, так как этот блог предназначен для Ссылка
Проблема в том, что когда я добавляюмоя VisualStateGroup с моими именами состояний BeforeLoaded и Loaded вообще не отображает элементы в ListBox.Я получаю синюю подсветку при наведении курсора и более яркую синюю при нажатии, чтобы выбрать, но фактическое содержимое элемента списка (случайный прямоугольник) отсутствует.
Когда я удаляю эту группу, прямоугольники отрисовываются идеально, но без какой-либо анимации (очевидно).Прилагается полный стиль для ItemContainerStyle ListBox.Остальная часть кода дословно от ссылки.
<Style x:Key="ListBoxItemStyle1" TargetType="ListBoxItem">
<Setter Property="Padding" Value="3"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="TabNavigation" Value="Local"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Grid Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LayoutStates">
<VisualState x:Name="BeforeLoaded">
<Storyboard>
<DoubleAnimation
Duration="00:00:00"
By="-196"
Storyboard.TargetName="contentProjection"
Storyboard.TargetProperty="GlobalOffsetX" />
<DoubleAnimation
Duration="00:00:00"
By="-180"
Storyboard.TargetName="contentProjection"
Storyboard.TargetProperty="RotationY" />
<DoubleAnimation
Duration="00:00:00"
By="-270"
Storyboard.TargetName="contentProjection"
Storyboard.TargetProperty="RotationX" />
</Storyboard>
</VisualState>
<VisualState x:Name="Loaded">
<Storyboard>
<DoubleAnimation
Duration="00:00:01"
To="0"
Storyboard.TargetName="contentProjection"
Storyboard.TargetProperty="GlobalOffsetX" />
<DoubleAnimation
Duration="00:00:01"
To="0"
Storyboard.TargetName="contentProjection"
Storyboard.TargetProperty="RotationY" />
<DoubleAnimation
Duration="00:00:01"
To="0"
Storyboard.TargetName="contentProjection"
Storyboard.TargetProperty="RotationX" />
</Storyboard>
</VisualState>
<VisualState x:Name="Unloaded" />
</VisualStateGroup>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimation Duration="0" To=".35" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="contentPresenter"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected"/>
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimation Duration="0" To=".75" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="fillColor2"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="FocusVisualElement">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="fillColor" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
<Rectangle x:Name="fillColor2" Fill="#FFBADDE9" IsHitTestVisible="False" Opacity="0" RadiusY="1" RadiusX="1"/>
<!--<ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}"/>-->
<ContentPresenter x:Name="contentPresenter"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}">
<ContentPresenter.Projection>
<PlaneProjection x:Name="contentProjection">
</PlaneProjection>
</ContentPresenter.Projection>
</ContentPresenter>
<Rectangle x:Name="FocusVisualElement" RadiusY="1" RadiusX="1" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>