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 7184717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:15:30+00:00 2026-05-28T18:15:30+00:00

I am using WPF’s ProgressBar object, which has a Value property, and I can

  • 0

I am using WPF’s ProgressBar object, which has a Value property, and I can pass it a constant int or decimal value and it doesn’t complain, but if I pass it a float (or int or string) variable value, it barfs an ArgumentException (e.g. "Message='0.02380952' is not a valid value for property 'Value'.") at me, which just seems preposterous to me, and has me stumped. The MS example I am following uses constant float values. The MS doc reference to the Value property however says it is an int, which seems just wrong since I can pass it constant .1 or .5 and get the right behavior, and my MS example uses 0 and 1 and the min and max values. So, what do I need to do here?

My code:

xaml:

<ProgressBar x:Name="prgProgress" Width="200" Height="20" Minimum="0" Maximum="100" />

c#:

float numMems = ListToShow.Count; 
float numDone = 0.0f;
int fracDone = 0;
string sProgress = "0%";
foreach (RAM_Member mem in ListToShow)
{
    if (isCanceled == true) break;
    mem.CalculateValues();
    numDone++;
    fracDone = (int)(100.0 * numDone / numMems);
    sProgress = (100 * numDone / numMems).ToString("0.") + "%";
    Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { prgProgress.SetValue(ProgressBar.ValueProperty, fracDone); }, null);
    Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { txtProgress.SetValue(TextBlock.TextProperty, sProgress); }, null);
}
  • 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-28T18:15:31+00:00Added an answer on May 28, 2026 at 6:15 pm

    You linked to the windows form equivalent, in WPF it’s a double, which means that if you use SetValue you will need to use that exact type as there is no implicit conversion.

    From SetValue:

    If the provided type does not match the type that is declared for the dependency property as it was originally registered, an exception is thrown. The value parameter should always be provided as the appropriate type.

    (Why don’t you use the wrapper instead? i.e. prgProgress.Value = fracDone)

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

Sidebar

Related Questions

Using WPF I have a list of rectangles (which can have an undefined number
Im using WPF which has a Storyboard class that has a Completed event. I
Using WPF .NET 4.0 in VS2010 RTM: I can't create a fullscreen WPF popup.
I'm building an application in C# using WPF. How can I bind to some
Using WPF, how can I get the duration of a video in a .wmv
Here's the situation: Using WPF I have an object set to the DataContext of
I am using WPF WebBrowser control. How can I detect all outgoing Http GET
I'm using WPF/.NET 4 and when I add the VirtualizingStackPanel.VirtualizationMode=Recycling property to my ListBoxes,
When using WPF databinding, I obviously can't do something along the lines of MyCollection
I am using WPF with model-view-viewmodel pattern. I have a ResultsView and ResultsViewModel which

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.