2024-06-25 01:37:45
// 定义事件属性
public static readonly RoutedEvent ClickRoutedEvent = EventManager.RegisterRoutedEvent("Click", RoutingStrategy.Bubble, typeof(ClickEventHandler), typeof(ControlName));
[Description("点击时发生")]
public event ClickEventHandler Click
{
add { AddHandler(ClickRoutedEvent, value); }
remove { RemoveHandler(ClickRoutedEvent, value); }
}
//触发点击事件,这里注册你控件上的那个点击按钮事件
void button_Click(object sender, RoutedEventArgs e)
{
e.RoutedEvent = ScrollChangedRoutedEvent;
e.Source = this;
this.RaiseEvent(e);
}