typ가 정수이기 때문에 이중 애니메이션이 작동하지 않습니다. Integeranimation 클래스가 있습니까? 아니면 다른 방식으로하고 있습니다. 저는 정적 애니메이션에는 관심이 없지만 이벤트 기반 (바람직하게는 프로그래밍 방식) 애니메이션에 관심이 있습니다.Silverlight에서 zIndex 속성에 애니메이션을 적용하는 방법은 무엇입니까?
public static void Swap(UIElement ui1, UIElement ui2, double seconds)
{
var z2 = (int)ui1.GetValue(Canvas.ZIndexProperty);
var z3 = (int)ui2.GetValue(Canvas.ZIndexProperty);
DoubleAnimation da1 = new DoubleAnimation();
DoubleAnimation da2 = new DoubleAnimation();
Duration d = new Duration(TimeSpan.FromSeconds(seconds));
da1.Duration = d;
da2.Duration = d;
Storyboard sb = new Storyboard();
Storyboard.SetTarget(da1, ui1);
Storyboard.SetTarget(da2, ui2);
Storyboard.SetTargetProperty(da1, new PropertyPath("(Canvas.ZIndex)"));
Storyboard.SetTargetProperty(da2, new PropertyPath("(Canvas.ZIndex)"));
sb.Duration = d;
sb.Children.Add(da1);
sb.Children.Add(da2);
da1.To = (double)z3;
da2.To = (double)z2;
sb.Begin();
}
private void Btn1_Click_1(object sender, RoutedEventArgs e)
{
var z2 = (int)Image2.GetValue(Canvas.ZIndexProperty);
var z3 = (int)Image3.GetValue(Canvas.ZIndexProperty);
Swap(Image2, Image3, 3);
}
그러나 기본 요소를 옮기고 동시에 zindex 속성을 전환했다면? 그럼 나는 그것을 움직일 수 있었다! – marko