本文整理汇总了C#中MediaPortal.UI.SkinEngine.Controls.Visuals.UIElement.AddHandler方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.AddHandler方法的具体用法?C# UIElement.AddHandler怎么用?C# UIElement.AddHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaPortal.UI.SkinEngine.Controls.Visuals.UIElement
的用法示例。
在下文中一共展示了UIElement.AddHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleEventAssignment
/// <summary>
/// Will create an event handler association for the current element.
/// </summary>
/// <remarks>
/// In contrast to method
/// <see cref="HandleMemberAssignment"/>,
/// this method can only be used for the current element, which is part of the
/// visual tree.
/// </remarks>
/// <param name="obj"><see cref="UIElement"/> which defines the event to assign the event
/// handler specified by <paramref name="value"/> to.</param>
/// <param name="evt"><see cref="RoutedEvent"/> which is defined on the class of
/// <paramref name="obj"/>.</param>
/// <param name="value">Name of the event handler to assign to the specified
/// event.</param>
protected void HandleEventAssignment(UIElement obj, RoutedEvent evt, string value)
{
if (_getEventHandler == null)
throw new XamlBindingException("Delegate 'GetEventHandler' is not assigned");
Delegate dlgt = _getEventHandler(this, evt.HandlerType.GetMethod("Invoke"), value);
try
{
obj.AddHandler(evt, dlgt);
}
catch (Exception e)
{
throw new XamlBindingException("Error assigning event handler", e);
}
}