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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:15:25+00:00 2026-05-22T01:15:25+00:00

I have a MVC class where i am inheriting INotifyPropertyChanged I have a clock

  • 0

I have a MVC class where i am inheriting INotifyPropertyChanged

I have a clock timer where for minute second and hour change the coontrol in xaml is updated with
OnPropertyChanged(“Time”); for example. this workes great for an analog clock in rotating its 3 hands. However, i want to make a digital clock by drawing its lines or toggle visibility in rectangle 7 segments.

so, in order to do that i have to do it in the code behind. Therefore, i need to be able to access that time that i created in the ClockViewModel : INotifyPropertyChanged class
so, from the code behind i want to use that time to toggle visibility to a rectangle or paint segments to display time.

I have an mvc analog clock that rotates hands from onproperty change but i dont see how to toggle visibility the same way or draw / paint.

so, is there a way to get the time from the class in the code behind? and or get the on property change when the time changes? or do i have to make a separate non MVC timer in the code behind?

here is the class

class ClockViewModel : INotifyPropertyChanged
{




        public ClockViewModel()
        {
            _timer = new System.Timers.Timer(1000);
            _timer.Elapsed += _timer_Elapsed;
            _timer.Start();
        }

what i want to do is get the constant time from the class run a switch statement on it so i can toggle visibility on some lines to show the time. Or, just draw the appropriate lines accordingly.

I can bind a textblock text to OnPropertyChanged(“DigitalTime”);
to display the time like digital however that defeats what i want to do.

  • 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-22T01:15:26+00:00Added an answer on May 22, 2026 at 1:15 am

    To do this I would add properties to my view model that defined the visibility for each line segment.

    Then each property getter would calculate whether the line should be visible based on the number to display.

    Now you could bind the Visibility property of each line to the corresponding property in your view model and call OnPropertyChanged(“”) (with an empty string) to raise all listeners for your view model.

    An easy improvement would be to factor out a user control that displayed one digit in your digital clock. Then you could reuse that control for each digit you needed to display.

    Edit:
    I won’t code the entire control for you (what is the use of that?), but let me make an example.
    I will assume that you have a set of line controls, maybe in a grid or something like that. To draw a number you need to show some lines and hide others.
    Now you need some xaml and a view model that supplies the data.

    Your Xaml should look something like this:

    <Line X1="10" X2="10" Y1="10" Y2="20" Visibility="{Binding Line1Visibility, Mode=OneWay}" />
    <Line X1="10" X2="20" Y2="10" Y2="10" Visibility="{Binding Line2Visibility, Mode=OneWay}" />
    .... and so on
    

    You need to define all the lines, but you don’t need to name them. Don’t use my X and Y values. They are for the example only. Also note the binding for the Visibilily. It is one-way since we don’t want to set it from our control.

    Now you need your view model. It should define properties for all the visibilities and a property where you set the number to display. It should be something like this:

    public class DigitalNumberViewModel : INotifyPropertyChanged
    {
      private int _numberToDisplay;
      public int NumberToDisplay
      { 
        get { return _numberToDisplay; }
        set 
        {
            _numberToDisplay = value;
            OnPropertyChanged("");
        }
      }
    
      public Visibility Line1Visibility 
      {
        get 
        {
          switch (NumberToDisplay)
          {
            case 0:
              return Visibility.Visible;
            case 1:
              return Visibility.Hidden;
            //... and so on
          }
        }
      }
    
      public Visibility Line2Visibility
      { .... }
    
      // ... and so on
    
    }
    

    Now you have a view model that defines the visibility for all the lines and a property that you can set that will call the property changed event for all properties in your view model. You should be able to fill in the rest yourself. 🙂

    Good luck!

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

Sidebar

Related Questions

I have the following types and classes: namespace MVC.Models public class Page { public
I have a Class Library project and MVC project in the one solution. My
I have an action like this: public class News : System.Web.Mvc.Controller { public ActionResult
I have a form in spring mvc 2 having command class Class1 I want
In an ASP.NET MVC application where I have the following model.. public class EventViewModel
I know in the MVC Framework, you have the Html Class to create URLs:
I use Spring MVC 3.0 and JSP. I have an object: public class ObjectWrapper
This is a MVC 3 project. Just for testing, I have public class MyRoleProvider
Azure web role (MVC 3 project) wont' start with Twilio controller class I have
I have a MVC project that has a Linq to SQL dbml class. It

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.