Tracking my Model in Watch Window

Ronald Rex 141 Reputation points

I was wondering what is best practice for instantiating a Model in your ViewModel class for purposes of adding it to the watch window so that you can see your Model Properties change while the application runs in debug mode. Thanks !!!!

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
913 questions
No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 41,831 Reputation points Microsoft Employee


    Do you implement the INotifyPropertyChanged in your Model?

    If so, you can add Console.WriteLine(value); in get/set method of properties. When you debug your application, you can see the value changes of properties of Model in output Window.

       public class MyModel : INotifyPropertyChanged  
           double hue;  
          public event PropertyChangedEventHandler PropertyChanged;  
          public double Hue  
                   if (hue != value)  
                       hue = value;  
                       Console.WriteLine("Hue:   " + value);  
                   return hue;  
           protected virtual void OnPropertyChanged(string propertyName)  
               PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));  

    Best Regards,

    Leon Lu

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful