storyboard

KeyTime property on KeyFrame object must be set to a non-negative TimeSpan value?

All, Can someone tell me why this KeyTime is telling me it is a negative value at runtime? I've removed some logic that builds a path to an image. public Storyboard CreateAnimationStoryBoard(DependencyObject dependencyObjectTarget,Image targetImage) { try { Storyboard sb = new Storyboard(); S...

WPF InvalidateMeasure not called during or after animation

I have a custom ListBox whith the following ListBoxItem style. It contains a few animations to scale the ListBoxItem when the mouse hovers over it. <Style x:Key="notesListBoxStyle" TargetType="{x:Type ListBoxItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> ...

Does a WPF storyboard animation continue to run when the affected control is hidden?

I am implementing a "marching ants" style animation by applying a StrokeDashOffset animation to a Rectangle control. I would like the animation to play when the rectangle is visible but not take up extra CPU cycles when it's hidden. Is WPF smart enough to automatically pause the animation when the affected control is hidden? ...

Why don't these animations work when I'm using a storyboard?

I've created a simple subclass of StackPanel that I can move around on the screen using an animated TranslateTransform. It looks like this: public class MovingStackPanel : StackPanel { public void BeginMove(Point translatePosition) { RenderTransform = new TranslateTransform(); Duration d = new Duration(new TimeS...

Remove/Stop Storyboard on DataContext change

General context : MVVM application. I have a View called JobView. Its DataContext is a class called Job. Within Job is a property called AuthorizationNeeded. A Border in the view has a style (from a resource dictionary) and that style has a data trigger which starts and stops a storyboard based on the bound property AuthorizationNeed...

WPF Animation Duration

I have a storyboard like the following Duration="0:0:1" Completed="DeviceExplorer_Completed"> The animation for some reason does not appear to be working linearly. If I change the duration to something like Duration="0:0:0.8" and assign the stroyboard to a MouseEnter event of a button, the animation moves but does not complet...

WPF Storyboard GetCurrentState

Hi, I am trying to detect when a storyboard is still active, still has an effect on a property(ie completed by still has a hold on the dependecy property it is animating). Completed="DeviceExplorer_Completed"> Duration="0:0:0.5"> In code I do Storyboard aStoryBoard = this.Resources["openDeviceExplorer"] as Storyboard; ...

Creating a templated silverlight control that has a story board.

I'm trying to create a templated silverlight control that has a simple animation (swap a few color properties). An example would be a control that is similar to the 'questions' menu item in stackoverflow. So the consumer of the control can specify the background color and the background color for the mouseover event. I've run into th...

XAML C# WPF Best efficient way to do an ordered sequence of animations

Hi everybody! I would like to do a sequence of animations on a label, for example, first do opacity animations from values 0 to 1 and vice versa and just at the end of opacity animation and not before a foreground animation. I would like to do it in XAML code and then start and finish de animation from C# code. Which is the best and eff...

Manipulating a Storyboard's target object

In the handler for the Completed event of a Storyboard, how do i get the element that the storyboard was being applied to? My Storyboard is part of an ItemTemplate: <ListBox x:Name="MyListBox" > <ListBox.ItemTemplate> <DataTemplate> <Grid x:Name="Container" Height="30" > <Grid.Resources> ...

Storyboard apply to all labels

Hi everyone ! I whant to apply a little storyboard to a collection of labels in my window. My storyboard is like that : <Storyboard x:Key="Storyboard1" AutoReverse="True" RepeatBehavior="Forever"> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label" Storyboard.TargetProperty="(Label.Foreground).(Soli...

Wait for all WPF animations to stop

Given a WPF window, which may or may not have animations, I'd like to wait until they are all done before continuing processing. Is there a generic way to do this. Currently I can do something like this: void WaitForAnimation(Storyboard storyboard) { WaitUntil(() => storyboard.GetCurrentState() == ClockState.Stopped); } But this...

Conflict When Two Storyboards Sets the Opacity Property?

Hi, Background: I have a WPF UserControl (MainControl - not shown in code below) that contains another one (called MyControl in the code below). MainControl has it's DataContext set to an object, that has a Project-property. When MainControl loads, the Project-property is always null. The problem: When MainControl loads, I want to f...

How do I animate image content in WPF?

I have a really basic user control with a button that has an image. I want to animate the image of the button, by changing it to a different image. <UserControl.Resources> <Image x:Key="GlyphDefault" Source="pack://application:,,,/X;component/images/Glyphs_Default.png" Height="8" Width="8" /> <Image x:Key="GlyphClicked" Source=...

Can I reference Storyboard resources in XAML defind Visual States?

I have six different objects with their own Visual State Managers. The Focused state of each object is the same. I want to define a single Focused State Storyboard resource and reference it in each of the 6 Focus Visual states. Can this be done? Here's my code (all in the same UserControl.Resources): <Storyboard x:Key="FocusedState"> ...

Storyboard as timer in WPF

Hi, I'm trying to do smooth animation in procedural code. For this (in Silverlight at least), it's recommended to use the Storyboard timer rather than a DispatcherTimer. So I use something like this: Storyboard _LoopTimer = new Storyboard(); public void StartAnimation() { _LoopTimer.Duration = TimeSpan.FromMilliseco...

Wpf: Storyboard.TargetName works, but Setter TargetName doesn't.

Hi, Let's say we have a XAML code like this: <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Border HorizontalAlignment="Center" VerticalAlignment="Center"> <Border.LayoutTransform> ...

Apply Storyboard Animation to DataGridTemplateColumn depending on Binding value change

I have a DataGridTemplateColumn on a WPF DataGrid which has a binding to a double type. I wish to apply a Storyboard Animation when the value goes down and another Storyboard Animation when the value goes up. I've got the following code to start with: <dg:DataGridTemplateColumn Header="My Double"> <dg:DataGridTemplateColumn.CellTemp...

wpf Storyboard.SetTarget vs Storyboard.SetTargetName

Why does Storyboard.SetTargetName works but Storyboard.SetTarget does not? Here xaml - <Grid Grid.Row="0" ClipToBounds="True"> <X:SmartContentControl x:Name="smartContent" Content="{Binding Path=MainContent}" ContentChanging="smartContent_ContentChanging"> <X:SmartContentControl.RenderTransform> ...

Game Development: How do you make a story game?

Hi, I made already a few simple games: enter a level, get up to the end, continue to the next level. But I'm still wondering how "real" game developers create games with a story. Here are a few things what a story game has (and where I'm wondering about how they make it) : A sequence of places the player have to visit and do there th...