0

Guys. I am implementing an MVVM code. I am using Fody. I created the BaseViewModel Successfully and here is it:

using System.ComponentModel;
namespace GProject_MVVM.ViewModel
{
    /// <summary>
    /// A base view model that fires Property Changed events as needed
    /// </summary>

    public class BaseViewModel : INotifyPropertyChanged
    {
        /// <summary>
        /// The event that is fired when any child property changes its value
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged = (sender, e) => { };
        /// <summary>
        /// Call this to fire <see cref="PropertyChanged"/> event
        /// </summary>
        /// <param name="name"></param>
        public void OnPropertyChanged(string name)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(name));
        }
    }
}

no problem with that but when I call it on WindowViewModel I got an error that OnPropertyChanged Not Defined here is my WindowViewModel

using System.Windows;

namespace GProject_MVVM.ViewModel
{
    /// <summary>
    /// THe View Model for Custom Flat Windows
    /// </summary>
    class WindowsViewModel
    {

        #region Private Member

        #endregion

        #region Public Properties


        #endregion

        #region Constructor
        // Default Constructor
        public WindowsViewModel(Window window)
        {
            mWindow = window;
            //Listen out for the window resizing
            mWindow.StateChanged += (sender, e) =>
            {
                OnPropertyChanged(nameof(ResizeBorderThickness)); // I got error here
            };

        }
        #endregion
    }
}
A.Hussainy
  • 113
  • 1
  • 9

1 Answers1

3

WindowsViewModel needs to inherit from BaseViewModel for it to have access to its members

public class WindowsViewModel : BaseViewModel {
    //...
}
Nkosi
  • 191,971
  • 29
  • 311
  • 378