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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:19:53+00:00 2026-05-23T05:19:53+00:00

I am relatively new to MVVM, and I am trying to code up a

  • 0

I am relatively new to MVVM, and I am trying to code up a basic Status Bar for an MVVM WPF application. I think I have the gist of things, but for some reason, the status bar does not always update, and I am not sure why.

In my ViewModel, I have a basic property that I update when I change a status message:

public string StatusMessage
{
    get { return _statusMessage; }
    set
    {
        if (value == _statusMessage) return;
        _statusMessage = value;
        base.OnPropertyChanged(() => this.StatusMessage);
    }
}

My OnPropertyChanged method (which I have in a base ViewModel class that implements INotifyPropertyChanged) looks like so (got this idea from Gunther Foidl; wish I could claim credit for it because I think it’s slick but I’m not quite that smart):

protected virtual void OnPropertyChanged<T>(Expression<Func<T>> exp)
    {
    MemberExpression me = exp.Body as MemberExpression;
    string propName = me.Member.Name;

    PropertyChangedEventHandler handler = this.PropertyChanged;
    if (handler != null)
    {
        handler(this, new PropertyChangedEventArgs(propName));
    }
}

At any rate, this all works great for all of my controls except one. On my MainWindow.xaml file, I have a StatusBarItem control bound to the above property, like so (the rest of the XAML has been trimmed for space reasons):

<StatusBarItem Grid.Column="0">
    <TextBlock TextTrimming="CharacterEllipsis" Text="{Binding Path=StatusMessage}" />
</StatusBarItem>

When I run my application (which hits a couple of DBs in addition to generating a document from template and a bunch of other fairly resource-intensive stuff), some, but not all, messages show up on the status bar. I have debugged and verified that the messages all make it into the StatusMessage property, above (and the ensuing private variable), they just don’t seem to be refreshing in the UI.

I have looked at several examples that use BackgroundWorker instances for ProgressBar controls, but haven’t seen any for StatusBarItem controls, and am not really sure how to translate one to the other.

I have also used Tasks before in previous C# 4.0 and WPF apps, and figure it’s probably a good way to go, but I haven’t really been able to figure out how/where to designate the UI task (I’ve always done it in the code-behind for the MainWindow before, but I’m striving for a zero-code-behind to stay in keeping with MVVM here).

I’m pretty sure that a multi-threaded approach is the way to go; I just don’t know enough about one approach (I know a little bit of this and a little bit of that) to make it work. I did see a couple of posts that used the older threading approach directly, but I pretty much stayed away from multithreading programming until I started using Tasks with .NET 4.0 (finding them a little easier to comprehend and keep track of), so I had a bit of trouble making sense of them.

Can anyone take pity on me and point me in the right direction, or suggest further debugging I can do? Thanks!

  • 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-23T05:19:54+00:00Added an answer on May 23, 2026 at 5:19 am

    1)Reflection based binding can be source of error sometimes because of inlining. Try to see what happens if you notifypropertychanged with simple string instead of reflection.

    2) if you are using multi threads there maybe a chance that you setup StatusMessage not from UIThread in that case it won’t be able to update UI, you could invoke setter code on UI Dispatcher to see if that helps

    3) check whether binding works , in constructor of xaml form modify StatusMessage directly on VM and see whether the change is shown on UI without invoking multithreaded service calls which introduce additional variables to simple textblock – string binding

    4) if that doesn’t help you could create a simple xaml form with single textblock bind it to your big viewmodel and see what happens, if nothing works you can begin cutting VM class to make it simpler so binding eventually starts to work and you find an error

    5) if you think that statusbar is the problem see if single textblock without statusbar (extract xaml part from your example) works

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

Sidebar

Related Questions

I'm relatively new to using WPF and the MVVM architecture. I have a question
I'm relatively new to MVVM and I'm trying to understand how INotifyPropertyChanged interface works
Im relatively new to PHP but have realized it is a powerfull tool. So
In a MVVM WPF application, I have a master-detail View that is used to
Relatively new to C# and MVVM, but I'm making a WP7 app using the
I'm relatively new to OOP, so wanted to clear a few things, I have
Relatively new to rails and trying to model a very simple family tree with
I'm relatively new to web application programming so I hope this question isn't too
I'm relatively new to Nant, what i'd like to do is have a task
I'm relatively new to Mercurial and my team is trying it out right now

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.