에 C#을에서 코드를 변환하는 동안 내가 VB.NET에 C# 코드의 다음 조각을 변환 할이 RaisePropertyChanged - 오류 VB.NET
/// <summary>
/// Attempts to raise the PropertyChanged event, and invokes the virtual AfterPropertyChanged
/// method, regardless of whether the event was raised or not.
/// </summary>
/// <param name="propertyName">
/// The property which was changed.
/// </param>
protected void RaisePropertyChanged(string propertyName)
{
this.VerifyProperty(propertyName);
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
//Get the cached event args.
PropertyChangedEventArgs args = GetPropertyChangedEventArgs(propertyName);
//Raise the PropertyChanged event.
handler(this, args);
}
}
변환 후, VB 코드는 다음과 같습니다
''' <summary>
''' Attempts to raise the PropertyChanged event, and invokes the virtual AfterPropertyChanged
''' method, regardless of whether the event was raised or not.
''' </summary>
''' <param name="propertyName">
''' The property which was changed.
''' </param>
Protected Sub RaisePropertyChanged(propertyName As String)
Me.VerifyProperty(propertyName)
Dim handler As PropertyChangedEventHandler = Me.PropertyChanged
If handler IsNot Nothing Then
'Get the cached event args.
Dim args As PropertyChangedEventArgs = GetPropertyChangedEventArgs(propertyName)
'Raise the PropertyChanged event.
handler.Invoke(Me, args)
End If
End Sub
이벤트 및 XML 속성 등과 관련하여 완벽한 변환을 제공하지 않는 Telerik 코드 변환기를 사용했습니다.
문제는 Visual Studio에서 다음 오류를 표시합니다. 오류 '공용 이벤트 PropertyChanged (보낸 사람 개체, e As System.ComponentModel.PropertyChangedEventArgs)'이벤트이며, 직접 호출 할 수 없습니다. 'RaiseEvent'문을 사용하여 이벤트를 발생시킵니다.
내가 VB.NET 구문에서 좋은 아니에요 및 :(
Dim 핸들러 As PropertyChangedEventHandler = Me.PropertyChanged – Harsha
VB에서 이벤트로 작업 할 때 AddressOf를 많이 사용해야합니다. 그래서 "AddressOf Me.PropertyChanged. – Terry