We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
namespace ValidCode.Wrapping { using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; public class WrappingProperties : INotifyPropertyChanged { private WithProperties withProperties = new WithProperties(); public event PropertyChangedEventHandler? PropertyChanged; public int P1 { get => this.withProperties.P1; set { if (value == this.withProperties.P1) { return; } this.withProperties.P1 = value; this.OnPropertyChanged(); } } public int P2 { get => this.withProperties.P2; #pragma warning disable INPC003 // Notify when property changes. set => this.TrySet(ref this.withProperties, new WithProperties { P1 = this.P1, P2 = value }); #pragma warning restore INPC003 // Notify when property changes. } protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) { this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } protected bool TrySet<T>(ref T field, T newValue, [CallerMemberName] string? propertyName = null) { if (EqualityComparer<T>.Default.Equals(field, newValue)) { return false; } field = newValue; this.OnPropertyChanged(propertyName); return true; } private class WithProperties { public int P1 { get; set; } public int P2 { get; set; } } } }
The text was updated successfully, but these errors were encountered:
It can be smarter there but probably not a super common case.
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: