本文介绍了需要Windows Phone 8的彩色动画示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。

我需要示例如何以编程方式为网格控件执行颜色动画。只需将背景颜色1更改为颜色2.



示例 []

谢谢。

Hello.
I need example how to do programmatically color animation for a grid control. Just change background color 1 to color 2.

Example http://blogs.msdn.com/b/silverlight_sdk/archive/2008/03/24/create-an-animation-in-code.aspx[^]
Thank you.

推荐答案

<Grid x:Name="btn_2" MouseLeftButtonDown="MouseLeftButtonDown_Button">

    <Grid.Background>
        <SolidColorBrush />
    </Grid.Background>

    <TextBlock x:Name="btn_2_tb" Text="2" TextAlignment="Center" Foreground="Black"></TextBlock>
</Grid>









// C#代码

ColorAnimation ca = new ColorAnimation();

ca.Duration = new Duration(TimeSpan.FromSeconds(1));

ca.From = Color.FromArgb(255,255,0,0);

ca.To = Color.FromArgb(255,0,0,255);



Storyboard.SetTarget(ca,btn_0);



Storyboard.SetTargetProperty(ca,new PropertyPath(UIElement.Background.Color ));

//改变原生测试的PropertyPath

//Panel.Background.Color

//Panel.Background.SolidColorBrush.Color

// (Panel.Background)。(SolidColorBrush.Color)



故事板sb =新故事板();

sb.Children.Add( ca);

sb.Begin();





//C# code
ColorAnimation ca = new ColorAnimation();
ca.Duration = new Duration(TimeSpan.FromSeconds(1));
ca.From = Color.FromArgb(255, 255, 0, 0);
ca.To = Color.FromArgb(255, 0, 0, 255);

Storyboard.SetTarget(ca, btn_0 );

Storyboard.SetTargetProperty(ca, new PropertyPath("UIElement.Background.Color"));
// alternative tested PropertyPath
// "Panel.Background.Color"
// "Panel.Background.SolidColorBrush.Color"
// "(Panel.Background).(SolidColorBrush.Color)"

Storyboard sb = new Storyboard();
sb.Children.Add(ca);
sb.Begin();


这篇关于需要Windows Phone 8的彩色动画示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 04:50