Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Storyboard/State Issues beta 2? RSS

3 replies

Last post Jun 24, 2008 01:58 PM by lee_sl

(0)
  • JonnyC

    JonnyC

    Member

    5 Points

    11 Posts

    Storyboard/State Issues beta 2?

    Jun 24, 2008 09:04 AM | LINK

    I have had a look around and have not been able to figure out if this a bug or me totally missing something.

     Create a storyboard in xaml and then trying to refrence it in the code behind file. 

     So there are 2 ways i would expect to be able to refrence this storyboard 1 being Show.Storyboard.*, the other being storyboard1.* , and then be able to modify them. So event handlers cannot be created either which is a bit annoying.

    Both these cause a null pointer on either Show or storyboard1

    Either way i am trying to either set the Value of the property to be an integer in the codebehind declared as private int newWidth = 150; so if anyone could show a different way to do that it would be great i had a brief attempt at binding but with no results.

    Thanks in advance
    J

    Xaml below

    <vsm:VisualState x:Name="Show">

    <Storyboard x:Name="storyboard1">

    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="mVideoPlayer" Storyboard.TargetProperty="(FrameworkElement.Width)">

    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="320"/>

    </DoubleAnimationUsingKeyFrames>

    </Storyboard>

    </vsm:VisualState>

    Storyboard Animation Bug

  • sinosoidal

    sinosoidal

    Member

    664 Points

    373 Posts

    Re: Storyboard/State Issues beta 2?

    Jun 24, 2008 10:08 AM | LINK

    Hi,

    What kind of error are you having?

    Are you writting this code by hand or are you using Blend? You should use Blend unless you really dominate the XAML.

    Where is this code? Inside a style?

    Can you post more code?

    Thx,

    Nuno

     

    --

    Imagining (and touching) the future
    http://www.nunosantos.net/
    http://www.myspace.com/sinosoidal
  • JonnyC

    JonnyC

    Member

    5 Points

    11 Posts

    Re: Storyboard/State Issues beta 2?

    Jun 24, 2008 01:29 PM | LINK

    Nullrefrence exception being thrown, pretty sure it used to work doing it this way, for storyboards etc

    Xaml:

    <UserControl

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    x:Class="SilverlightApplication4.Page"

    Width="640" Height="480" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows">

    <Grid x:Name="LayoutRoot" Background="White" >

    <vsm:VisualStateManager.VisualStateGroups>

    <vsm:VisualStateGroup x:Name="State">

    <vsm:VisualStateGroup.Transitions>

    <vsm:VisualTransition Duration="00:00:01"/>

    </vsm:VisualStateGroup.Transitions>

    <vsm:VisualState x:Name="Red">

    <Storyboard>

    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">

    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="106"/>

    </DoubleAnimationUsingKeyFrames>

    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">

    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="3"/>

    </DoubleAnimationUsingKeyFrames>

    </Storyboard>

    </vsm:VisualState>

    <vsm:VisualState x:Name="Blue">

    <Storyboard x:Name="BlueStory">

    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">

    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="25"/>

    </DoubleAnimationUsingKeyFrames>

    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">

    <SplineDoubleKeyFrame KeyTime="00:00:00" Value="185"/>

    </DoubleAnimationUsingKeyFrames>

    <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">

    <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF1E05FB"/>

    </ColorAnimationUsingKeyFrames>

    </Storyboard>

    </vsm:VisualState>

    </vsm:VisualStateGroup>

    </vsm:VisualStateManager.VisualStateGroups>

    <Rectangle Height="120" HorizontalAlignment="Left" Margin="83,63,0,0" VerticalAlignment="Top" Width="122" Fill="#FF7C1212" Stroke="#FF000000" RenderTransformOrigin="0.5,0.5" x:Name="rectangle">

    <Rectangle.RenderTransform>

    <TransformGroup>

    <ScaleTransform/>

    <SkewTransform/>

    <RotateTransform/>

    <TranslateTransform/>

    </TransformGroup>

    </Rectangle.RenderTransform>

    </Rectangle>

    <Button Height="100" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="100" Content="Blue" Margin="104,0,0,0" x:Name="BlueButton" Click="BlueButton_Click"/>

    <Button Height="100" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="100" Content="Red" Margin="0,0,0,0" x:Name="RedButton" Click="RedButton_Click"/>

    </Grid>

    </UserControl>

     

    cs:

    using System.Windows;

    using System.Windows.Controls;

    namespace SilverlightApplication4

    {

    public partial class Page : UserControl

    {

    public Page()

    {

    // Required to initialize variables

    InitializeComponent();

    }

    private void RedButton_Click(object sender, RoutedEventArgs e)

    {

    Red.Storyboard.Begin();

    }

    private void BlueButton_Click(object sender, RoutedEventArgs e)

    {

    BlueStory.Begin();

    }

    }

    }

     

    I am looking to edit the storyboard targets once they have been created / run indivdually

  • lee_sl

    lee_sl

    Contributor

    4222 Points

    864 Posts

    Re: Re: Storyboard/State Issues beta 2?

    Jun 24, 2008 01:58 PM | LINK

    you dont need VSM here. you could just move the Storyboards in to the UserControl Resources section and when the button is clicked you can do

    (this.Resources["sb1"] as Storyboard).Begin(); //sb1 is the key given for the storyboard

    ----------------------------------------------
    Available for consulting in Dallas, TX
    http://leeontech.wordpress.com/