Wpf VisualStateManager:设置面板.ZIndex
为什么我不能在VisualStateManager中设置Panel.ZIndex? 我正在构建一个旋转木马用户界面,正在努力找出为什么无法为Panel.ZIndex设置值 此XAML嵌入到VisualState元素中:Wpf VisualStateManager:设置面板.ZIndex,wpf,xaml,Wpf,Xaml,为什么我不能在VisualStateManager中设置Panel.ZIndex? 我正在构建一个旋转木马用户界面,正在努力找出为什么无法为Panel.ZIndex设置值 此XAML嵌入到VisualState元素中: <Storyboard> <VisualState> <ObjectAnimationUsingKeyFrames Storyboard.TargetNa
<Storyboard>
<VisualState>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetName="MidRightRectangle"
Storyboard.TargetProperty="Rectangle.(Panel.ZIndex)">
<DiscreteObjectKeyFrame KeyTime="0" Value="4" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
未正确设置
TargetProperty
试试这个
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualState x:Name="ZIndexChanged">
<Storyboard>
<Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.ZIndex)" Storyboard.TargetName="MidRightRectangle">
<EasingInt32KeyFrame KeyTime="0" Value="4"/>
</Int32AnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
未正确设置
TargetProperty
试试这个
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualState x:Name="ZIndexChanged">
<Storyboard>
<Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.ZIndex)" Storyboard.TargetName="MidRightRectangle">
<EasingInt32KeyFrame KeyTime="0" Value="4"/>
</Int32AnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
我还从前面的答案中了解到,我可以像这样解析动画:
<Int32Animation Storyboard.TargetName="MidRightRectangle"
Storyboard.TargetProperty="(Panel.ZIndex)"
To="4"
Duration="0:0:.15">
</Int32Animation>
我还从前面的答案中了解到,我可以像这样解析动画:
<Int32Animation Storyboard.TargetName="MidRightRectangle"
Storyboard.TargetProperty="(Panel.ZIndex)"
To="4"
Duration="0:0:.15">
</Int32Animation>
但请注意,它在Silverlight中是Canvas.ZIndex
,但在WPF中是Panel.ZIndex
。哦,很抱歉,您只需要用Panel替换Canvas即可。但也可以将关键帧替换为Int32?我刚才注意到的另一件事是,VisualState
标记应该包装故事板,而不是相反。请看我的最新答案。谢谢!所以ObjectAnnimationSingKeyframes只适用于实际对象。但请注意,Silverlight中是Canvas.ZIndex
,而WPF中是Panel.ZIndex
。哦,很抱歉,您只需要用Panel替换Canvas。但也可以将关键帧替换为Int32?我刚才注意到的另一件事是,VisualState
标记应该包装故事板,而不是相反。请看我的最新答案。谢谢!因此ObjectAnnimationSingKeyframes仅应用于实际对象。