Hi
Is there an option to change the template for the function "Convert to Property with Change Notification"
The default setting:
int myProperty;
public int MyProperty
{
get
{
return myProperty;
}
set
{
if (myProperty == value)
return;
myProperty = value;
RaisePropertyChanged(nameof(MyProperty));
}
}
But I use it every time with "OnPropertyChange();" but not with "RaisePropertyChanged(nameof(MyProperty));"
How can I change it?
Thanks
Michael
Hi Michael,
Thank you for providing the code sample. The 'Convert to Property with Change Notification' code action automatically finds a method in your class (or base classes) that raises the PropetyChanged event and generates a call of this method. In your case, it found the RaisePropertyChanged method. If I get you right, then your class contains two methods that raise the PropertyChanged event. Please provide us with code of these methods (OnPropertyChange and RaisePropertyChanged) or with the whole code of a problematic class. It will help us better understand your case and improve the logic of our features which generate the change notification template.
Hi Alexander
In my base class there some OnPropertyChange methodes:
for simple call PropertChanged Event (don't had to write the name of the propertiy)
public void OnPropertyChanged([CallerMemberName]string propertyName = null)
{
OnPropertyChanged(propertyName, true); -> call main OnPropertyChange methode
}
For select, if the PropertyChange Event will call with Parameter "makeDirty"
makeDirty tells if a class (i.e. addresses) had changes, and I had to Display to save it
public void OnPropertyChanged(bool makeDirty, [CallerMemberName]string propertyName = null)
{
OnPropertyChanged(propertyName, makeDirty);
}
the main methode for setting all other important properties on OnPropertyChange
public void OnPropertyChanged(string propertyName, bool makeDirty)
{
RaisePropertiesChanged(propertyName);
if (_IsSuppressDirty)
return;
if (makeDirty)
{
IsDirty = true;
if (IsDirtyChanged != null)
{
var e = new EventArgsPropertyInListChanged()
{
PropertyName = propertyName,
ChangedItem = this
};
IsDirtyChanged(this, e);
}
}
//Validate();
}
As I wrote the CodeRush set the Notification to RaisePropertyChanged of the DevExpress.Mvvm Namespace
I hope it is now clearer.
I want to say CodeRush, do not use the "RaisePropertyChanged" from DevExpress.Mvvm Namespace, use my "OnPropertyChanged()" Methode
Thanks
Michael
Thank you for providing the code samples. We currently understand your case. Please give us some time to discuss the best way to support this functionality in our product. We will notify you.
Thank you for your patience. We have decided to improve logic CodeRush features that generate property change notification. So, they will automatically detect that the OnPropertyChanged method should be used in your case. We will notify you of our progress.