Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7682919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:40:40+00:00 2026-05-31T18:40:40+00:00

I have a WPF project using CM. I have a progress bar that I

  • 0

I have a WPF project using CM. I have a progress bar that I would like to animate smoothly. I have a storyboard containing a DoubleAnimation. The problem is that when I try to bind the Duration of the DoubleAnimation to a property on my view model, I get a TargetInvocationException on running the program.

The XAML for the progress bar looks like this:

<ProgressBar Name="ProgressBar" Width="400" Height="18">
    <ProgressBar.Style>
        <Style>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=IsMeasuring}" Value="True">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation 
                                    Storyboard.Target="{Binding TemplatedParent}" 
                                    Storyboard.TargetProperty="Value" 
                                    From="0" 
                                    To="100" 
                                    Duration="{Binding MeasurementDuration}" 
                                />
                            </Storyboard>
                        </BeginStoryboard>
                    </DataTrigger.EnterActions>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </ProgressBar.Style>
</ProgressBar>

While the property in my view model looks like this:

private Duration measurementDuration = new Duration(TimeSpan.FromSeconds(1));
public Duration MeasurementDuration
{
    get { return measurementDuration; }
    private set
    {
        measurementDuration = value;
        NotifyOfPropertyChange(() => MeasurementDuration);
    }
} 

I feel that the answer is staring straight at me, but I simply cannot find it. Thanks in advance for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:40:42+00:00Added an answer on May 31, 2026 at 6:40 pm

    as far as i know, a binding to an animation in this implementation way as yours throws always an error.
    In the case to change properties of an Timeline-Object while it is animated, you have to use the methods <StoryboardName>.Begin() to create a new clock for the Storyboard and <StoryboardName>.Seek() to jump to the reached duration.

    Before you call the <name>.Begin() method, you change your desired properties and it should work.

    Their exists a example in the msdn:
    http://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=wpfsamples&DownloadId=7734

    In fact, that in the msdn example “only” the KeyFrames-objects of a an TimeLine-Object will be changed, you have to call the Storyboard.Stop() method before you change the Duration-property.

    Try it and maybe it helps 🙂

    Kind regards
    Sb

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a solution where I have a WPF project that is using
I have WPF application project and I'm using EF. I want something like this.
I have a project I'm working on that requires our WPF application read SMS
I'm playing with my first wpf project using the mvvm pattern. I have Microsoft
I have a method in a C# / Wpf project and I'd like to
I have a WPF project using MVVM. I have two views: ClientView and CommentView
I have a WPF project with an AssemblyInfo.cs that groups multiple CLR namespaces into
I have a WPF project with a border using the following style. The plan
I have a wpf project where I am using INotifyPropertyChanged on a property which
I have a WPF project and I have added support for localization using Satellite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.