我正在建立一个Windows 7应用程序在Silverlight。
我在ListBox中有一个内容列表。当用户按下按钮时,“删除”图标应出现在列表中的每个项目旁边。理想情况下,列表项将滑过,图标将被动画化。
我不知道做这件事最好的方法是什么。我不熟悉银光动画。一种方法:为包含图标和实际内容的ListBox创建一个数据模板。如果用户点击按钮,切换图标的可见性。将事件处理程序附加到正在点击的图标上。(我不知道如何制作动画。)
还是有别的办法让这件事成功?
更新:好的,我有一个很好的动画,其中的内容滑出和返回。但是,我想为列表中的每个项目添加一个图标。我该怎么做?
<VisualStateManager.CustomVisualStateManager>
<ic:ExtendedVisualStateManager/>
</VisualStateManager.CustomVisualStateManager>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="EditingStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:1"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Editing">
<Storyboard>
<DoubleAnimation Duration="0" To="60" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="pivotItem" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
<VisualState x:Name="NotEditing">
<Storyboard>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="pivotItem" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>而且,现在这是硬编码为一个特定的控件。如何将其更改为用户当前正在查看的pivotItem?
发布于 2010-11-03 20:06:40
这是VisualStates的一个“规范”案例--只需创建一个打开图标的状态和一个关闭图标的状态,然后在它们之间切换。状态之间的动画可以非常容易地完成。我建议您使用WP7混合(免费),并检查此视频作为起点:
http://expression.microsoft.com/en-us/ee426922.aspx
编辑:
对于问题的第2部分,只需将图标添加到ItemTemplate中,并通过VS动画使其从外部滑行和/或增长(改变宽度/高度)。
您应该将VisualStates添加到ListBox中的项模板中;通过这样做,您将能够在VS动画中引用控件的正确实例和图标。
发布于 2010-11-03 20:41:52
在你的列表框控件中使用故事板,如果你没有想法,试着在windows 7中使用expression,然后添加一个关键帧,就像Adobe一样。
https://stackoverflow.com/questions/4090996
复制相似问题