Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtendedObservableObject and new attribute #37

Open
KSemenenko opened this issue Feb 15, 2019 · 2 comments
Open

ExtendedObservableObject and new attribute #37

KSemenenko opened this issue Feb 15, 2019 · 2 comments

Comments

@KSemenenko
Copy link

KSemenenko commented Feb 15, 2019

Description

I propose to expand the base class with useful functions.

AutoProperty Description

public int FirstProperty
{
	get => GetValue<int>();
	set => SetValue(value);
}

I think that this method of implementation to simplify the work with properties.

Attributes Description

NotifyProperty
DependsOnProperty
that allow you to keep track of property updates and call PropertyChange for related properties

public class MockExtendedViewModel : ObservableObject
{

	[NotifyProperty(nameof(ThirdProperty))]
	public int FirstProperty
	{
		get => GetValue<int>();
		set => SetValue(value);
	}

	[DependsOnProperty(nameof(FirstProperty))]
	public int SecondProperty
	{
		get => GetValue<int>();
		set => SetValue(value);
	}

	public int ThirdProperty
	{
		get => GetValue<int>();
		set => SetValue(value);
	}
}

If you assign a new value to FristProperty, you will also be instantiated by the OnPropertyChanged event for ThirdProperty.

Also trigger events for SecondProperty because it depends on FirstProperty.

@jamesmontemagno If you are interested in this I will do PR
I also have such a small library, and I think that this code can be useful.

@jamesmontemagno
Copy link
Owner

If you want to put in a PR i would be interested in what it looks like for sure.

@valdetero
Copy link

@KSemenenko have you seen the attribute usage in PropertyChanged.Fody?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants