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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:49:13+00:00 2026-05-27T19:49:13+00:00

I am working on a WP7 app that displays some times on one page.

  • 0

I am working on a WP7 app that displays some times on one page. I have a code behind that has an ObservableCollection of objects. Each object has a calculated property that uses DateTime.Now to determine the time that’s displayed on the page. I can’t figure out how to “notify” that the property has changed since the property doesn’t change, the current time is changing (just once per second). Any ideas? Here’s the jist of what I’ve got:

//my business object
public class Widget
{
    private string _name;
    public string Name
    {
        get { return _name; }
        set { _name = value; }
    }

    private DateTime? _start;
    public DateTime? Start
    {
        get { return _start; }
        set { _start = value; }
    }

    public TimeSpan? TimeSinceStart
    {
        get { return Start.HasValue ? DateTime.Now - Start.Value : default(TimeSpan); }
    }
}

//my viewmodel
public class WidgetDisplayerViewModel : BaseViewModel
{
    public WidgetDisplayerViewModel()
    {
        TimeUpdateTimer.Tick += new EventHandler(TimeUpdateTimer_Tick);
        TimeUpdateTimer.Interval = new TimeSpan(0, 0, 1);
        TimeUpdateTimer.Start();
    }

    public WidgetDisplayerViewModel(string selectedCategory) : this()
    {
        Category = MockDataService.GetCategory(selectedCategory);
        Category.Widgets = MockDataService.GetWidgets(selectedCategory).ToObservableCollection();
    }

    public DispatcherTimer TimeUpdateTimer = new DispatcherTimer();

    private DateTime _currentTime;
    public DateTime CurrentTime
    {
        get { return _currentTime; }
        set {
            _currentTime = value;
            NotifyPropertyChanged("CurrentTime");
        }
    }


    public Category Category { get; set; }

    void TimeUpdateTimer_Tick(object sender, EventArgs e)
    {
        CurrentTime = DateTime.Now;
    }
}

And then the view is very simple and just needs to display the CurrentTime and then for each Widget in the collection it needs to show the TimeSinceStart. The CurrentTime is getting updated each second by the timer and that gets propogated to the view. That one is easy because the timer is setting it and so I have a chance to call NotifyPropertyChanged(“CurrentTime”), but how would I “notify” that all of the TimeSinceStart getters should be called to update the calculated value for each Widget since I’m not setting them?

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-27T19:49:14+00:00Added an answer on May 27, 2026 at 7:49 pm

    You’ll have to manually refresh the property one way or another. I see you already have a timer ticking every second. So I can suggest you two solutions:

    1/ Define a “UpdateTime” method in the Widget object. In this method, call NotifyPropertyChanged("TimeSinceStart"). When the timer is ticking, enumerate the list of widgets, and call the UpdateTime method on each.

    2/ Create a global object implementing the INotifyPropertyChanged interface, and holding the value of CurrentTime. Make each of your Widget objects subscribe to the PropertyChanged event of this global class to know when the time is updated. Then, when the event is triggered, call NotifyPropertyChanged("TimeSinceStart").

    • 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 simple WP7 app that displays BART arrivals from their real
I have this memory game app that I'm working on, trying to learn WP7.
I'm working on a WP7 app that uses bing maps to display ~600 pushpins.
I'm working on an app that has rows in the following format. I've numbered
I'm working on a WP7 mango App that makes use of Linq2SQL for data
I'm working on a WP7.1 app that records audio and plays it back. I'm
I have a WP7 app where I'm trying to reconstruct an HTTPWebRequest that I
I have a ListBox in a WP7 app page which I bind to a
I'm working on a WP7 app and I've had some trouble updating a TextBlock
I have a WP7 app that I recently upgraded to WP7.1 (including the MVVM-Lite

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.