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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:37:40+00:00 2026-05-27T04:37:40+00:00

I didnt use WPF for a long time so I’m quite sure this is

  • 0

I didnt use WPF for a long time so I’m quite sure this is an easy question for most of you but here is my xaml code :

<Grid>
    <ProgressBar Name="Progress" Width="200" Height="20" Minimum="0" Maximum="100" Margin="10"/>
</Grid>

and here is the C# code :

namespace WpfApplication1
{
    public partial class MainWindow : Window, INotifyPropertyChanged
    {
        private int _MyInt;
        public int MyInt
        {
            get { return _MyInt; }
            set
            {
                _MyInt = value;
                RaisePropertyChanged("MyInt");
            }
        }

        public MainWindow()
        {
            InitializeComponent();

            MyInt = 99;

            Random random = new Random();
            System.Timers.Timer aTimer = new System.Timers.Timer();
            aTimer.Elapsed += (sender, e) =>
            {
                MyInt = random.Next(0, 100);
            };
            aTimer.Interval = 500;
            aTimer.Enabled = true;

            Binding b = new Binding();
            b.Source = MyInt;
            b.Mode = BindingMode.OneWay;
            Progress.SetBinding(ProgressBar.ValueProperty, b);
        }
        public event PropertyChangedEventHandler PropertyChanged;
        public void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

When the application starts I got a 99 value on my ProgressBar so the binding seems to work but then, it doesn’t refresh at all…

  • 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-27T04:37:41+00:00Added an answer on May 27, 2026 at 4:37 am

    Progress.Value = MyInt is simply setting the value to whatever the current value in MyInt is. This is not the same as binding the value, which means the value will point to MyInt, not be a copy of MyInt

    To create a binding in the code-behind, it would look something like this:

    Binding b = new Binding();
    b.Source = this;
    b.Path = new PropertyPath("MyInt");
    Progress.SetBinding(ProgressBar.ValueProperty, b);
    

    An alternative is to just bind the value in your XAML and update it as needed:

    <ProgressBar Name="Progress" Value="{Binding MyInt}" />
    

    Then in the code behind: MyInt = newValue;

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

Sidebar

Related Questions

I asked a question yesterday which got answers but didnt answer the main point.
I need exactly this: Click Me But just for WPF. And I know, that
This is probably mostly a question about how to use the VS 2010 IDE
Can someone explain this WPF behaviour? <Page xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml> <Grid> <!-- Rounded mask -->
I have a javascript which I didn't write but I need to use it
I have a large javascript which I didn't write but I need to use
We have a .net application that we didn't develop, but use. I can tell
I have a WPF application which has a DirectX component within it. This component
Trying to understand this binding process of the WPF. See the code at the
I'm just getting into C#, so forgive me if this is a basic question.

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.