Das eigene Routed-Event erstellen als OnClick

 

 

DATEI: MeinEigenerKnopf.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace ERoutedEvents
{
public class MeinEigenerKnopf : Button
{

public static RoutedEvent TabEvent = EventManager.RegisterRoutedEvent("Tab", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MeinEigenerKnopf));

public event RoutedEventHandler Tab
{
add { AddHandler(TabEvent, value); }
remove { RemoveHandler(TabEvent, value); }
}

protected override void OnClick()
{
RoutedEventArgs routedEventArgs = new RoutedEventArgs(TabEvent);
RaiseEvent(routedEventArgs);
}

}
}

 

Top