本文整理汇总了C#中RoutedEvent.IsLegalHandler方法的典型用法代码示例。如果您正苦于以下问题:C# RoutedEvent.IsLegalHandler方法的具体用法?C# RoutedEvent.IsLegalHandler怎么用?C# RoutedEvent.IsLegalHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoutedEvent
的用法示例。
在下文中一共展示了RoutedEvent.IsLegalHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddHandler
/// <summary>
/// Adds a routed event handler for the particular
/// <see cref="RoutedEvent"/>
/// </summary>
/// <remarks>
/// The handler added thus is also known as
/// an instance handler <para/>
/// <para/>
///
/// NOTE: It is not an error to add a handler twice
/// (handler will simply be called twice) <para/>
/// <para/>
///
/// Input parameters <see cref="RoutedEvent"/>
/// and handler cannot be null <para/>
/// handledEventsToo input parameter when false means
/// that listener does not care about already handled events.
/// Hence the handler will not be invoked on the target if
/// the RoutedEvent has already been
/// <see cref="RoutedEventArgs.Handled"/> <para/>
/// handledEventsToo input parameter when true means
/// that the listener wants to hear about all events even if
/// they have already been handled. Hence the handler will
/// be invoked irrespective of the event being
/// <see cref="RoutedEventArgs.Handled"/>
/// </remarks>
/// <param name="routedEvent">
/// <see cref="RoutedEvent"/> for which the handler
/// is attached
/// </param>
/// <param name="handler">
/// The handler that will be invoked on this object
/// when the RoutedEvent is raised
/// </param>
/// <param name="handledEventsToo">
/// Flag indicating whether or not the listener wants to
/// hear about events that have already been handled
/// </param>
public void AddHandler(
RoutedEvent routedEvent,
Delegate handler,
bool handledEventsToo)
{
// Verify Context Access
this.VerifyAccess();
if (routedEvent == null)
{
throw new ArgumentNullException("routedEvent");
}
if (handler == null)
{
throw new ArgumentNullException("handler");
}
if (!routedEvent.IsLegalHandler(handler))
{
throw new ArgumentException("handler");
}
InstanceEventHandlersStore.AddRoutedEventHandler(routedEvent, handler, handledEventsToo);
}