Skip to content

[ViewModelGenerateInterface] including INotifyPropertyChanged interface #106

@Telespaz

Description

@Telespaz

Hi,

i want to subscribe to the PorpertyChanged event of my ViewModel. But the generated Interface does not include the INotifyPropertyChanged interface. Because of this i always need to cast my ViewModel to subscribe to the event.

Example:

[ViewModelGenerateInterface]
[ViewModel]
public partial class MyClass
{
    public void Foo() { }
}

leads to this generation:

partial class MyClass : global::MvvmGen.ViewModels.ViewModelBase, IMyClass
{
    public MyClass()
    {
        this.OnInitialize();
    }

    partial void OnInitialize();
}

public interface IMyClass
{
    void Foo();
}

would be nice if it does

public interface IMyClass : INotifyPropertyChanged
{
    void Foo();
}

I could then do :

IMyClass myClass = new MyClass();

myClass.PropertyChanged += MyClass_PropertyChanged;

instead of:

IMyClass myClass = new MyClass();

if(myClass is INotifyPropertyChanged vm)
    vm.PropertyChanged += MyClass_PropertyChanged;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions