Reputation: 1337
VB Code:
Public Event PropertyChanged(ByVal sender As Object, ByVal e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
Public Sub OnPropertyChanged(ByVal e As PropertyChangedEventArgs)
If PropertyChangedEvent IsNot Nothing Then
RaiseEvent PropertyChanged(Me, e)
End If
End Sub
Converted C# code
public event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged;
public delegate void PropertyChangedEventHandler(object sender, PropertyChangedEventArgs e);
public void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChangedEvent != null) {
if (PropertyChanged != null) {
PropertyChanged(this, e);
}
}
}
Error is:
Error 1 The name 'PropertyChangedEvent' does not exist in the current context
Upvotes: 0
Views: 461
Reputation: 108790
Don't use explicit interface implementation but just make it a public method.
Or cast this
to the interface to call the handler. ((INotifyPropertyChanged)this).PropertyChanged
Upvotes: 0
Reputation: 39600
Your event is called "PropertyChanged", not "PropertyChangedEvent".
Also, the event is explicitly implemented, which means, you'd have to use this:
((INotifyPropertyChanged)this).PropertyChanged
instead of PropertyChanged
to access the event.
And as Oded pointed out, the code checks twice for the event. You can remove one of those checks.
Upvotes: 3