I use DoubleAnimationUsingKeyFrames for animation on controls e.g. TextBlock like below, it works perfectly if done in XAML:
Code: Select all
<Storyboard x:Name="objFadeInControls">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="textblock1" Storyboard.TargetProperty="Opacity">
<EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="0.0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1.0">
<EasingDoubleKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseIn"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="textblock1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)">
<EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="-100"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<CircleEase EasingMode="EaseIn"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<TextBlock x:Name="textblock1" Text="Some Text" Opacity="0">
<TextBlock.RenderTransform>
<CompositeTransform/>
</TextBlock.RenderTransform>
</TextBlock>
As there will be many controls to be animated at once, I have created a custom control that will generate all given controls automatically. That's why I have to code behind. However, when I do exactly the same, the animation doesn't work:
Code: Select all
Storyboard m_sbFadeIn = new Storyboard();
EasingDoubleKeyFrame _edkf1 = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)),
Value = 0.0
};
EasingDoubleKeyFrame _edkf2 = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(300)),
Value = 1.0,
EasingFunction = new CircleEase { EasingMode = EasingMode.EaseIn }
};
DoubleAnimationUsingKeyFrames _daukf = new DoubleAnimationUsingKeyFrames();
_daukf.KeyFrames.Add(_edkf1);
_daukf.KeyFrames.Add(_edkf2);
Storyboard.SetTargetName(_daukf, "textblock1");
Storyboard.SetTargetProperty(_daukf, new PropertyPath(FrameworkElement.OpacityProperty));
m_sbFadeIn.Children.Add(_daukf);
_edkf1 = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)),
Value = -100
};
_edkf2 = new EasingDoubleKeyFrame
{
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(300)),
Value = 0,
EasingFunction = new CircleEase { EasingMode = EasingMode.EaseIn }
};
_daukf = new DoubleAnimationUsingKeyFrames();
_daukf.KeyFrames.Add(_edkf1);
_daukf.KeyFrames.Add(_edkf2);
Storyboard.SetTargetName(_daukf, "textblock1");
Storyboard.SetTargetProperty(_daukf, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)"));
m_sbFadeIn.Children.Add(_daukf);
The result should be the same... or did I miss anything? I'm using 2.0.0-alpha49-068 for my project