本文整理汇总了C#中RoutedEvent.AddClassHandler方法的典型用法代码示例。如果您正苦于以下问题:C# RoutedEvent.AddClassHandler方法的具体用法?C# RoutedEvent.AddClassHandler怎么用?C# RoutedEvent.AddClassHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoutedEvent
的用法示例。
在下文中一共展示了RoutedEvent.AddClassHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bubbling_Class_Handlers_Should_Be_Called
public void Bubbling_Class_Handlers_Should_Be_Called()
{
var ev = new RoutedEvent(
"test",
RoutingStrategies.Bubble | RoutingStrategies.Tunnel,
typeof(RoutedEventArgs),
typeof(TestInteractive));
var invoked = new List<string>();
EventHandler<RoutedEventArgs> handler = (s, e) => invoked.Add(((TestInteractive)s).Name);
var target = this.CreateTree(ev, null, 0);
ev.AddClassHandler(typeof(TestInteractive), handler, RoutingStrategies.Bubble);
var args = new RoutedEventArgs(ev, target);
target.RaiseEvent(args);
Assert.Equal(new[] { "2b", "1" }, invoked);
}
示例2: Typed_Class_Handlers_Should_Be_Called
public void Typed_Class_Handlers_Should_Be_Called()
{
var ev = new RoutedEvent<RoutedEventArgs>(
"test",
RoutingStrategies.Bubble | RoutingStrategies.Tunnel,
typeof(TestInteractive));
var target = CreateTree(ev, null, 0);
ev.AddClassHandler<TestInteractive>(x => x.ClassHandler, RoutingStrategies.Bubble);
var args = new RoutedEventArgs(ev, target);
target.RaiseEvent(args);
Assert.True(target.ClassHandlerInvoked);
Assert.True(target.GetVisualParent<TestInteractive>().ClassHandlerInvoked);
}