No Target Was Specified For System.Windows.Media.Animation.DoubleAnimation

I am using Syncfusion WPF components 28.1.41 in a my WPF .Net application. I am using the SfStepProgressBar and most of the time it behaves perfectly. However sometimes I seem to get an unhandled exception "No target specified for DoubleAnimation", and the stack trace always seems to show this is due to a call from the SfStepProgressBar. It is inconsistant as the same "inputs" mostly work, but sometimes don't. It's not that my code has failed to specify any "target", because my definitions would be the same each time.

My latest exception shows that it was this line in Storyboard.cs which raised the exception 

FunctionCall.png

And here is the stack trace

StackTrace.png


Here are the definitions of my storyboards used for the animation

    <!-- Define the storyboard for Image zoom animation -->

    <Storyboard x:Key="ZoomImageStoryboard">
        <!-- Animate the ScaleX and ScaleY properties to zoom the image -->
        <DoubleAnimation
            Storyboard.TargetName="ImageTransform"
            Storyboard.TargetProperty="ScaleX"
            From="1.0" To="1.1" Duration="0:0:0.2" AutoReverse="True" RepeatBehavior="3x"/>


        <DoubleAnimation
            Storyboard.TargetName="ImageTransform"
            Storyboard.TargetProperty="ScaleY"
            From="1.0" To="1.1" Duration="0:0:0.2" AutoReverse="True" RepeatBehavior="3x"/>
    </Storyboard>


    <!-- Define the storyboard for Text zoom animation -->
    <Storyboard x:Key="ZoomTextStoryboard">
        <!-- Animate ScaleX (horizontal scaling) -->
        <DoubleAnimation Storyboard.TargetName="TextTransform"
                         Storyboard.TargetProperty="ScaleX"
                         From="1.0" To="2.0" Duration="0:0:0.3" AutoReverse="True"/>




        <!-- Animate ScaleY (vertical scaling) -->
        <DoubleAnimation Storyboard.TargetName="TextTransform"
                         Storyboard.TargetProperty="ScaleY"
                         From="1.0" To="2.0" Duration="0:0:0.3" AutoReverse="True"/>
    </Storyboard>


And here is a single DataTemplate used for one of the stamp states, which includes the triggering of the animation

 <!--- Player has this stamp, and there is an unclaimed reward -->

 <DataTemplate x:Key="RewardUnclaimedStamp">
     <Grid Background="Transparent">
         <Grid.RowDefinitions>
             <RowDefinition/>
             <RowDefinition/>
         </Grid.RowDefinitions>

         <!-- Show "Unclaimed" but give it some animation to attract the eye -->
         <TextBlock Grid.Row="0" Text="Unclaimed!" FontSize="27" Foreground="LimeGreen" FontWeight="Bold" HorizontalAlignment="Center">
             <TextBlock.RenderTransform>
                 <ScaleTransform x:Name="TextTransform"/>
             </TextBlock.RenderTransform>
             <TextBlock.RenderTransformOrigin>
                 <!-- Center of the TextBlock -->
                 <Point X="0.5" Y="0.5"/>
             </TextBlock.RenderTransformOrigin>
             <TextBlock.Triggers>
                 <EventTrigger RoutedEvent="TextBlock.Loaded">
                     <BeginStoryboard Storyboard="{StaticResource ZoomTextStoryboard}"/>
                 </EventTrigger>
             </TextBlock.Triggers>
         </TextBlock>

         <TextBlock Grid.Row="1" Text="{Binding RewardTitle}"

                    Width="140" TextWrapping="Wrap"

                    FontSize="27" TextAlignment="Center" />

     </Grid>

 </DataTemplate>


If I was principally just doing things wrong, I would expect it not to work, or give me these exceptions all the time. But it works 99% of the time.

Is there anything you can spot, which you would advise me I am not applying correctly?


Thanks, Paul


22 Replies

YM Yathavakrishnan Mohan Syncfusion Team January 30, 2025 11:15 AM UTC

 Hi Paul,
 

We could not reproduce the reported issue using the information provided. For your reference, we’ve attached a sample that we used to try to replicate the issue on our end. Can you please modify the attached sample as per your sample and share it back with us with detailed replication steps. This will assist us in conducting a more thorough investigation.


Regards,

Yathavakrishnan M


Attachment: WPF_Sample_888cb741.zip


PP Paul Parkins January 31, 2025 09:12 AM UTC

Hi,

Thanks for replying and providing the template to modify.  I think it may take some time as my application's use of the SfStepProgressBar is a little more complex than I originally described. But having given this further thought, I think it might be very relevant to my problem....

We use the SfStepProgressBar as a representation of a "stampcard", each having a unique layout (no. of markers, marker images, marker text...). Our users can switch between different stampcards, thereby causing me to need to redefine the SfStepProgressBar's properties.  I have noted that this issue appears to occur most often when the user moves between stampcards, perhaps before the animations on the marker's controls from the  previous stampcard has finished animating. FYI, I have animation on both the marker image and text, if a "stamp" is of a certain state only. There could be none, one, or multiple stamps with this same state and animating.

As my code knows it is redefining the layout, I am thinking it should do something to either stop any animations in progress, or wait until they complete. 


Now I have further explained my application a little, do my reasonings on the possible issue sound likely?  Can you suggest any way that I can cancel/freeze updates/animations on the SfStepProgressBar whilst I am updating it's properties?


Thanks, Paul








YM Yathavakrishnan Mohan Syncfusion Team February 3, 2025 02:34 PM UTC

Hi Paul,

We
can achieve your requirement by using the  AnimationDurationProperty . The default value of the AnimationDuration property is 500ms. To meet your requirement, set the AnimationDuration property to 0, it will complete  the animation before another one is executed. Please refer to the code snippet below and the user guide link for more details.
 

//set the Animation duration
sfProgressbar.AnimationDuration = new TimeSpan(0);


UG Link :
Selected Item in WPF Step ProgressBar control | Syncfusion<sup>®</sup>;
 



PP Paul Parkins February 3, 2025 03:53 PM UTC

Hi. That's a great suggestion, but wouldn't that only affect the animation of the progress marker line? In reality I have added animation to some of the markers images and text

For example, my marker image is supplied via a datatemplater selector

        <DataTemplate x:Key="RewardUnclaimedMarker">
            <Grid>
                <!-- Show "Redeem Now" icon but give it some animation to attract the eye -->
                <Image Source="/FrontEnd;component/Images/RedeemNowIcon.png" Width="100" Height="100">
                    <Image.RenderTransform>
                        <ScaleTransform x:Name="ImageTransform"/>
                    </Image.RenderTransform>
                    <Image.Triggers>
                        <EventTrigger RoutedEvent="Image.Loaded">
                            <BeginStoryboard Storyboard="{StaticResource ZoomImageStoryboard}"/>
                        </EventTrigger>
                    </Image.Triggers>
                </Image>
            </Grid>
        </DataTemplate>

and my marker text has it's own DataTemplate provided by a different selector

        <DataTemplate x:Key="RewardUnclaimedStamp">
            <Grid Background="Transparent">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>


                <!-- Show "Unclaimed" but give it some animation to attract the eye -->
                <TextBlock Grid.Row="0" Text="Unclaimed!" FontSize="27" Foreground="LimeGreen" FontWeight="Bold" HorizontalAlignment="Center">
                    <TextBlock.RenderTransform>
                        <ScaleTransform x:Name="TextTransform"/>
                    </TextBlock.RenderTransform>
                    <TextBlock.RenderTransformOrigin>
                        <!-- Center of the TextBlock -->
                        <Point X="0.5" Y="0.5"/>
                    </TextBlock.RenderTransformOrigin>
                    <TextBlock.Triggers>
                        <EventTrigger RoutedEvent="TextBlock.Loaded">
                            <BeginStoryboard Storyboard="{StaticResource ZoomTextStoryboard}"/>
                        </EventTrigger>
                    </TextBlock.Triggers>
                </TextBlock>


                <TextBlock Grid.Row="1" Text="{Binding RewardTitle}"
                           Width="140" TextWrapping="Wrap"
                           FontSize="27" TextAlignment="Center" />
            </Grid>
        </DataTemplate>





PP Paul Parkins February 4, 2025 07:56 PM UTC

Hi,

I have an updated. Your suggestion does in fact address my problem. Previously the animation duration was always at the default value. But now I set it to 0 before I re-layout and restore to 500ms when I want to show the first marker.

I had always assume that it was my introduction of animation of the text and image, which was triggered by the step progress bar, as opposed to it being the animation of the progress bar marker itself.

Thanks for your help!


Paul



YM Yathavakrishnan Mohan Syncfusion Team February 5, 2025 10:18 AM UTC

Hi Paul,

We are glad to know that your issue is resolved. Please reach out to us if you need any further assistance.

Regards,
Yathavakrishnan M



PP Paul Parkins February 5, 2025 12:02 PM UTC

Unfortunately it seems I was a bit premature, and although harder to cause the issue, I can still cause the issue. I am currently proving whether or not the issue ever occurs, if I leave this animation at 0.

If it doesn't, then we either need to decide to leave this disabled, or come up with a better solution (in terms of when I redefine the animation so we do see the marker display).


I'll post back when I can




YM Yathavakrishnan Mohan Syncfusion Team February 6, 2025 11:55 AM UTC

We tried to reproduce the reported issue using the provided details, but we were unable to reproduce it. For your reference, we’ve attached the sample we used in an attempt to reproduce the issue. Could you please modify the attached sample to match your setup and share it back with us along with detailed replication steps? This will help us conduct a more thorough investigation.


Attachment: WPF_Sample_3e542dde.zip


PP Paul Parkins February 10, 2025 08:00 PM UTC

Hi,

I spent quite some time producing a sample project that demonstrates the issue. I have tried to make this as brief as I could, but it needs to replicate the usage of my real application, This not the same codebase, but I am applying the same principles.   Whilst I am not asking you to help debug my application, I will take on suggestions if you think I have not taken the correct approach. But I am sure you will agree that even if I am not doing this the best way, I should not be able to cause the SfStepProgressBar to indirectly raise this DoubleAnimation exception?

I think it important you understand how my real world application is attempting to use the progress bar:

  • Another company provides membership based functionality, including a digital version of paper Stampcards (where the holder is given a new stamp on each visit, which may make them eligible for a reward)
  • A member may have multiple stampcards associated with their account, and each stampcard may have a different number of stamps, with different rewards available at different stamp levels.
  • Our application presents a UI of these stampcards using the SfStepProgressBar to represent any single stampcard at a time
  • The user may use "Next" and "Prev" buttons to cycle between their stampcards, with loop-around.
In this sample application I have eliminated all uses of step item and step marker template selectors, and the animations I had added to the steps in my real end application. Although I have added comments throughout my sample, the following may help your understanding better:
  • It uses MVVM so most of the code is in MainWindow_ViewModel.cs
  • I have hardcoded the source of data (that would normally be download from the member's account, in a list 

    _StampcardsList in the VM constructor. A timer is used to simulate selecting the first stampcard, 2 seconds after launch

  • The property StampcardIndex dictates which stampcard of those available should be current, and represented via the progress bar's layout

    • Disable animation

    • Load the StampStepsCollection (ItemSource for progress bar) via LoadStampcardAtIndex()

    • Restore animation

    • Select the appropriate SelectedStampIndex (SelectedIndex for progressbar)


Demonstration #1
In this demo, it is representative of what I want to do... disable animation (to avoid crash) while I redefine the ItemSource collection, then restore animation and set the active step
  1. In the VM ensure the USE_TIMER_FOR_DELAYED_MARKER conditional variable is commented out
  2. Run the application
  3. Press "Next"
  4. Note we get the exception
At this point the Output window in VS will show that the animation duration was left at 00:00:00.
Image_9565_1739216300452

The exception occurs  due to me attempting to set SelectedStampIndex, so the marker displays the active stamp/step,
Image_6150_1739216268786
but you can see in the call stack the exception is raised due to a call from the progress bar's BeginAnimation (when animation is disabled)Image_9491_1739216385534

Before setting  SelectedStampIndex here, I really wanted to restore the animation, but if you were to uncomment the lines that can do that, you will then experience exactly the same issue, but when setting the StampcardAnimationDuration property instead of the SelectedStampIndex property. Same problem, different bound property

Demonstration #2

In this demo, it is representative of a workaround I saw necessary to add to my end application. In this I use a timer to separate the loading of the collection driving the progress bar, and setting of the SelectedIndex to show the active markers (which actually are not currently looking correct in this sample, but I didn't want to get distracted with that)

  1. In the VM ensure the USE_TIMER_FOR_DELAYED_MARKER conditional variable is NOT commented out
  2. Rebuild and run the application
  3. Use "Next" and "Prev" buttons to cycle between scratchcards
  4. Note this workaround does seem to have helped, including showing the marker animation. But.....
  5. Click and keep clicking "Next" as quick as you can. Sooner or later you will get the DoubleAnimation crash again

Apologies for length of this post, but I felt it important I pass on a much info as I if I think it relevant.

Regards

Pau





Attachment: WPF_Customer__Sample_830ac8d5.zip


YM Yathavakrishnan Mohan Syncfusion Team February 11, 2025 02:32 PM UTC

Hi Paul,
 
Demonstration #1
In this demo, it is representative of what I want to do... disable animation (to avoid crash) while I redefine the ItemSource collection, then restore animation and set the active step
  1. In the VM ensure the USE_TIMER_FOR_DELAYED_MARKER conditional variable is commented out
  2. Run the application
  3. Press "Next"
  4. Note we get the exception
We have reviewed the issue in the provided sample and the mentioned steps. The issue is occurring on the code side, not with the StepProgress bar. A call stack screenshot is attached for your reference. Please investigate the issue on your end.
Demonstration #2
  1. In the VM ensure the USE_TIMER_FOR_DELAYED_MARKER conditional variable is NOT commented out
  2. Rebuild and run the application
  3. Use "Next" and "Prev" buttons to cycle between scratchcards
  4. Note this workaround does seem to have helped, including showing the marker animation. But.....
  5. Click and keep clicking "Next" as quick as you can. Sooner or later you will get the DoubleAnimation crash again
We were able to reproduce the reported issue with the provided details on our end, and currently we are analyzing it. We will provide further details on February 13th, 2024

Regards,
Yathavakrishnan M




PP Paul Parkins replied to Yathavakrishnan Mohan February 11, 2025 03:31 PM UTC

Hi,

Thanks for your prompt response.  With regard to Demonstration #1, this is exactly the problem I expected.

If you when you had that call stack you had pressed the "Show External Code" button, you would see that whilst my code has modified a property, and raised OnPropertyChanged (that the SfStepProgressBar has it's SelectedIndex property bound to), the callstack shows the progress bar has attempted to start an animation when it was disabled Image_5044_1739287823386


regards

Paul



YM Yathavakrishnan Mohan Syncfusion Team February 12, 2025 01:18 PM UTC

Hi Paul,

With the provided details we could able to reproduce the demontration1 issue and as mentioned earlier we will check the above reported issues and update further details on February 13, 2025


Regards,
Yathavakrishnan M



RB Rajavignesh BalaSankar Syncfusion Team February 13, 2025 02:26 PM UTC

We are still validating on this error details with high priority and will update further details on February 17, 2025.



PP Paul Parkins replied to Rajavignesh BalaSankar February 13, 2025 03:12 PM UTC

Thank you. Whilst I would like to eliminate this issue from my customer experience, it is currently only on limited site trial and I don't consider it "high" priority so no need to rush it through. I do appreciate your consideration though.



YM Yathavakrishnan Mohan Syncfusion Team February 17, 2025 03:53 PM UTC

Hi Paul,

Upon further analysis, the issue occurred due to accessing the Progressbar properties before the items source gets updated in the UI thread also before changing the item resource. we need to reset all the properties. In the provided sample we were reset the animation duration but SelectedStampIndex is not reset so we request to set the SelectedStampIndex 0 before changing the item recourse also we recommend to use dispatcher to update other properties of the progreessbar after changing the item source. In order to avoid accessing the progressbar before the item source get updated. Please refer to the code snippet below.

        private void LoadStampcardAtIndex(int index)

        {

            ProgressBarAnimationDuration = new TimeSpan(0); // Stop all animation

 

            //Set SelectedStampIndex to 0

            SelectedStampIndex = 0;

            StampStepsCollection = null;

            if ((index >= 0) && (index < _StampcardsList.Count))

            {

                //SelectedStampIndex = -1;

               

                StampStepsCollection = _StampcardsList[index].StampItems;

            

               

 

                // Having switched the steps of the progress bar, I now want

                // to either make no markers active, or activate all those up

                // to the marker repesenting the no. of stamps they have.

 

#if USE_TIMER_FOR_DELAYED_MARKER

                //ProgressBarAnimationDuration = new TimeSpan(0, 0, 0, 0, 500); // Use default 500ms marker animation period

                Debug.WriteLine($"After loading stampcard, will set SelectedStampIndex to {_StampcardsList[index].NumStampsAchieved - 1}");

                 //However if I do this here, I get a DoubleAnimation exception!

               

                Application.Current.Dispatcher.Invoke(() => {

                    SelectedStampIndex = _StampcardsList[index].NumStampsAchieved - 1;

                }, System.Windows.Threading.DispatcherPriority.Render);

#else

                // So instead, let's use a timer to do it very soon after

                Debug.WriteLine($"After loading stampcard, will set progress marker after timer delay...");

                myMarkerTimer.Start();

               

               

#endif

 

                // Space out stamp items depending on how many stamps are on the stampcard

                ResizeStampcardSpacingForThisManyStamps(_StampcardsList[_StampcardIndex].StampItems.Count);

 

                // Refresh description of which stampcard is selected and how many stamps they have

                OnPropertyChanged(nameof(StampcardRecSummary));

            }

        }

Additionally, we have modified the sample you provided and attached it for your reference.


Regards,
Yathavakrishnan M


Attachment: WPF_Customer__Sample_3633d186.zip


PP Paul Parkins replied to Yathavakrishnan Mohan February 18, 2025 05:51 PM UTC

Hi, thanks for the update.

Interesting. I had also been "de-selecting" any marker in my own application (so as to ensure I see the animation on a new stampcard), though I had been setting the index to -1 to represent "nothing selected", in line with other collection based Syncfusion controls. After all, even if I have a marker at index 0, who's to say I want it to be represented as active?  Or does there always have to be one active marker?

I added your suggested changes to my copy of the sample application and it did indeed appear to resolve it. No matter how quickly I clicked Prev/Next, I did not experience any exceptions.  But I noted there was no animation as I had disabled it before switching stampcards, in line with previous advice here.

I though the most obvious thing would be to also do it via the dispatcher

Application.Current.Dispatcher.Invoke(() =>
{
    ProgressBarAnimationDuration = new TimeSpan(0, 0, 0, 0, 500); // Use default 500ms period
    SelectedStampIndex = _StampcardsList[index].NumStampsAchieved - 1;
}, System.Windows.Threading.DispatcherPriority.Render);

But although I now see an animation, it is possible to create the exception again by clicking Prev/Next fast.


Are you able to suggest a method of safely restoring animation, before the selected marker is set?


Thanks

Paul




YM Yathavakrishnan Mohan Syncfusion Team February 19, 2025 01:19 PM UTC

Hi Paul,
We have set the default value of SelectedStampIndex to 0, but we can change the default value to -1 if needed. We attempted to reproduce the reported issue by clicking the buttons multiple times using the provided sample when the SelectedStampIndex value is -1, but we were unable to replicate the issue. For your reference, we have attached the sample and a video demonstrating the steps we followed. If you continue to experience the issue, please modify the sample as needed and share it with us. This will help us conduct a more thorough investigation.

 
Regards,
Yathavakrishnan M

Attachment: WPF_Customer__Sample_2c3d05cc.zip


PP Paul Parkins replied to Yathavakrishnan Mohan February 21, 2025 11:28 AM UTC

Hi,

I didn't need to amend your sample. I just built it, ran it, and clicked fast. Please see my video attatched


regards

Paul


Attachment: Screen_Recording_20250221_112435_ef3c483a.zip


YM Yathavakrishnan Mohan Syncfusion Team February 24, 2025 12:51 PM UTC

Hi Paul,

 

We have confirmed the issue “System.InvalidOperationException thrown while changing the animation of StepProgressBar continuously” as a defect in our product and we will include the fix for this issue in our Weekly NuGet Release which will be available on March 4, 2025.

 

Please use the below feedback link to track the status of the reported bug.

System.InvalidOperationException thrown while changing the animation of StepProgressBar continuously in WPF | Feedback Portal

 

Note: If you require a patch for the reported issue in any of our Essential Studio Main or SP release version, then kindly let us know the version, so that we can provide a patch in that version based on our SLA policy.

 

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”

 

Regards,

Yathavakrishnan M



YM Yathavakrishnan Mohan Syncfusion Team March 4, 2025 10:57 AM UTC

We have included the fix for this “System.InvalidOperationException thrown while changing the animation of StepProgressBar continuously” in our latest weekly release (28.2.9). Upgrade to the latest version, to get the issue resolved.

 

Root Cause:

StepProgressBar was not loaded properly when the ItemSource was continuously changed.

 

Please use the below link to download our latest NuGet,

Nuget Link:

NuGet Gallery | Syncfusion.SfProgressBar.WPF 28.2.9

 

Feedback link

System.InvalidOperationException thrown while changing the animation of StepProgressBar continuously in WPF | Feedback Portal
 



PP Paul Parkins March 10, 2025 10:33 AM UTC

Hi,

Thanks very much. I can confirm that your fix does appear to address the issue in my sample application. Please thank your developers.


Paul



YM Yathavakrishnan Mohan Syncfusion Team March 11, 2025 06:08 AM UTC

Hi Paul,

Thanks for your response. You can get back to us if you need any further assistance.


Regards,

Yathavakrishnan M


Loader.
Up arrow icon