locked
DiscreteObjectKeyFrame of Animation not worked in win ce 6.0 RRS feed

  • Question

  • Hi,

    I have a storyboard like below:

            <Storyboard x:Name="BatteryFull" RepeatBehavior="Forever">
              <DoubleAnimationUsingKeyFrames
                 BeginTime="00:00:00"
                 Storyboard.TargetName="rectangle"
                 Storyboard.TargetProperty="Width">
                 <SplineDoubleKeyFrame KeyTime="00:00:0.1" Value="34"/>
                 </DoubleAnimationUsingKeyFrames>
              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="textBlock"  Storyboard.TargetProperty="(TextBlock.FontFamily)">
                  <DiscreteObjectKeyFrame Value="Fonts/Fonts.zip#B Titr" KeyTime="00:00:0.1">
                  <!--
                    <DiscreteObjectKeyFrame.Value>
                      
                    </DiscreteObjectKeyFrame.Value>  
                -->
                  </DiscreteObjectKeyFrame>
              </ObjectAnimationUsingKeyFrames>
              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="textBlock"  Storyboard.TargetProperty="(TextBlock.Text)">
                  <DiscreteObjectKeyFrame Value="Full" KeyTime="00:00:0.1">
                  <!--
                    <DiscreteObjectKeyFrame.Value>
                      
                    </DiscreteObjectKeyFrame.Value>  
                -->
                  </DiscreteObjectKeyFrame>
              </ObjectAnimationUsingKeyFrames>    
              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="textBlock"  Storyboard.TargetProperty="(TextBlock.Foreground).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
                  <DiscreteObjectKeyFrame Value="Black" KeyTime="00:00:0.1">
                  <!--
                    <DiscreteObjectKeyFrame.Value>
                      Black
                    </DiscreteObjectKeyFrame.Value>  
                    -->
                  </DiscreteObjectKeyFrame>
              </ObjectAnimationUsingKeyFrames>
              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="textBlock"  Storyboard.TargetProperty="(TextBlock.FontSize)">
                  <DiscreteObjectKeyFrame Value="9.333" KeyTime="00:00:0.1">
                  <!--
                    <DiscreteObjectKeyFrame.Value>
                       9.333
                    </DiscreteObjectKeyFrame.Value>  
                -->
                  </DiscreteObjectKeyFrame>
              </ObjectAnimationUsingKeyFrames>                                  
            </Storyboard>

            <TextBlock x:Name="textBlock" Margin="17,8,15,8" TextWrapping="Wrap" FontFamily="Webdings" FontSize="18.667">
                <TextBlock.Foreground>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="Black" Offset="1"/>
                        <GradientStop Color="#FFFF0B0B" Offset="0.345"/>
                    </LinearGradientBrush>
                </TextBlock.Foreground>
            </TextBlock>

    I loaded this xaml file by LoadResourceDictionary function in c++ in embedded system at win ce 6.0. But DiscreteObjectKeyFrame  sections not worked. Why? What must I do?

    Tuesday, October 16, 2012 12:34 AM

Answers

  • I loaded this xaml file by LoadResourceDictionary function in c++ in embedded system at win ce 6.0. But DiscreteObjectKeyFrame  sections not worked. Why? What must I do?

    Hi namnabat,

    As far as I know, ObjectAnimationUsingKeyFrames allows to target animations at properties that are not Double, Point, or Color. We can animate the Visibility property of a UIElement.

    <Rectangle Height="100" HorizontalAlignment="Left" Margin="201,110,0,0" Name="myRect" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="200" >
                <Rectangle.Resources>
                    <Storyboard Duration="0:0:2" x:Name="storboard1">
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="myRect" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <ObjectAnimationUsingKeyFrames.KeyFrames>
                                <DiscreteObjectKeyFrame KeyTime="00:00:01">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Collapsed</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames.KeyFrames>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </Rectangle.Resources>
            </Rectangle>
    
     private void button1_Click(object sender, RoutedEventArgs e)
            {
                storboard1.Begin();
            }

    Best Regards,

    Wednesday, October 17, 2012 5:27 AM
    Moderator