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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:56:32+00:00 2026-05-19T04:56:32+00:00

This is my scenario. I have internal class with a standard int property. public

  • 0

This is my scenario. I have internal class with a standard int property.

public class Session : INotifyPropertyChanged {
    public event PropertyChangedEventHandler PropertyChanged;

    private ushort _Level;
    public ushort Level
    {
        get { return _Level; }
    }

    private void OnPropertyChanged(string name)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(name));
    }

    // a timer code here updates the _Level property every 60 seconds
    // and calls OnPropertyChange("Level");
}

In my UI window, I have a label that binds to the Session instance and displays the Level value.

 <TextBlock Name="LevelTextBlock" Text="{Binding SessionInstance.Level, StringFormat='0%'}" />

And the window constructor has this code:

 public MyWindow()
    {
        SessionInstance = new Session();

        this.InitializeComponent();
    }

    public Session SessionInstance { get; set; }

However, as you can guess, when I update the value of _Level, the UI doesn’t update the textblock. Adding DependancyProperty inside the Session class is unacceptable. I could do this on the window, but then I still need notifier that would check the value back to the Session instance.
I was wondering if there’s elegant way of doing this. I can’t think of anything, other than running another timer in the window that would check and refresh the textblock value.
Any thoughts?

  • 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-19T04:56:33+00:00Added an answer on May 19, 2026 at 4:56 am

    Implement INotifyPropertyChanged. There is even an tool which can do that automatically for all of your properties (or only ones marked by attribute, it is fairly configurable).

    DependencyProperty is overkill if you don’t need any of its other features (value inheritance, binding FROM the property etc.), it is best used for control properties, not model properties.

    EDIT:

    Correctly implemented it looks like this:

    private string familyName;
    public string FamilyName
    {
        get { return familyName; }
        set 
        {
            if (value != familyName)
            {
                familyName = value;
                OnPropertyChanged("FamilyName");
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this scenario well, i'll let the model explain. public class ScheduleMonthlyPerDayModel {
I have an hierarchical structure of classes like this public class Class1 { internal
I was wondering how other people implemented this scenario. I have an internal rails
Please Consider this scenario: We have a base class called clsMain : class clsMain
//class = Person public string Name { get; internal set; } I have an
I am a NHibernate newbie. Suppose you have a Customer class like this public
Consider this scenario. We have an internal Rails 2 app that connects to a
This is my code: public class MyCollection { internal static Dictionary<string, CheckBox> MyCheckBox =
Imagine this scenario: You have a desktop and a laptop. The desktop has a
So I have this scenario <div id=editor contenteditable=true> <div id=list>Hello</div> </div> I want to

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.