To Override Or Not to Override. That is the question.

RogerSchlueter-7899 1,236 Reputation points
2023-05-19T05:52:33.49+00:00

Consider this code-behind class for my Transactions class.

Public Class Transactions
    Implements INotifyPropertyChanged

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

    Private_Remainder As Decimal
    Public Property Remainder As Decimal
        Get
            Return _Remainder
        End Get
        Set(value As Decimal)
            _Remainder = value
           OnPropertyChanged(NameOf(Remainder))
        End Set
    End Property

    << Other propertieswe and methods >>

    Private Sub OnPropertyChanged(Name As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(Name))
    End Sub

End Class

Pretty routine ... except I get this error:

sub 'OnPropertyChanged' shadows an overridable method in the base class 'FrameworkElement'. To override the base method, this method must be declared 'Overrides'

But when I add the Overrides qualifier, I get this error message:

sub 'OnPropertyChanged' cannot be declared 'Overrides' because it does not override a sub in a base class.

I've never seen this error before and obviously cannot fix both errors. I would also note that the property binding in the XAML file are not working. I do not know if this is a related issue.

What do you recommend?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,681 questions
{count} votes