Fix syntax issue in class-handlers.md

Fixes syntax issue for Avalonia class handler. Add remark about strong typing.
This commit is contained in:
Stephen Monaco 2022-11-05 22:49:46 -04:00 коммит произвёл GitHub
Родитель affca94f90
Коммит 84a1ed50fb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -20,15 +20,15 @@ private static void HandleMyEvent(object sender, RoutedEventArgs e)
```csharp
static MyControl()
{
MyEvent.AddClassHandler<MyControl>(x => x.HandleMyEvent);
MyEvent.AddClassHandler<MyControl>((x, e) => x.HandleMyEvent(e));
}
private void HandleMyEvent(object sender, RoutedEventArgs e)
private void HandleMyEvent(RoutedEventArgs e)
{
}
```
{% endtab %}
{% endtabs %}
Notice that in WPF you have to add the class handler as a static method, whereas in Avalonia the class handler is not static: the notification is automatically directed to the correct instance.
Notice that in WPF you have to add the class handler as a static method, whereas in Avalonia the class handler is not static: the notification is automatically directed to the correct instance. The `sender` parameter typical of event handlers is not necessary in this case and everything remains strongly typed.