本文整理汇总了C#中Windows.UI.Xaml.UIElement.AddHandler方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.AddHandler方法的具体用法?C# UIElement.AddHandler怎么用?C# UIElement.AddHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.UIElement
的用法示例。
在下文中一共展示了UIElement.AddHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HoldListener
public HoldListener(UIElement target)
{
_pointerPressedHandler = new PointerEventHandler(Target_PointerPressed);
_pointerMovedHandler = new PointerEventHandler(Target_PointerMoved);
_pointerReleasedHandler = new PointerEventHandler(Target_PointerReleased);
_pointerCanceledHandler = new PointerEventHandler(Target_PointerCanceled);
_pointerCaptureLostHandler = new PointerEventHandler(Target_PointerCaptureLost);
Target = target;
Target.AddHandler(UIElement.PointerPressedEvent, _pointerPressedHandler, true);
Target.Tapped += Target_Tapped;
_timer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(0.7)
};
_timer.Tick += Timer_Tick;
}
示例2: OnApplyTemplate
protected override void OnApplyTemplate()
{
try
{
container = GetTemplateChild(PART_ROOT_NAME) as Grid;
inker = GetTemplateChild(PART_INKER_NAME) as InkCanvas;
if (container != null && inker != null)
{
container.Visibility = Visibility.Visible;
InitializeInker();
root = VisualTreeHelperEx.FindRoot(container, false);
contentPresenter = VisualTreeHelperEx.FindRoot(container, true);
//contentPresenter.PointerEntered += Element_PointerEntered;
contentPresenter.AddHandler(UIElement.PointerEnteredEvent, new PointerEventHandler(Element_PointerEntered), true);
//contentPresenter.PointerExited += Element_PointerExited;
contentPresenter.AddHandler(UIElement.PointerExitedEvent, new PointerEventHandler(Element_PointerExited), true);
//contentPresenter.PointerCanceled += Element_PointerCanceled;
contentPresenter.AddHandler(UIElement.PointerCanceledEvent, new PointerEventHandler(Element_PointerCanceled), true);
//contentPresenter.PointerReleased += Element_PointerCanceled;
contentPresenter.AddHandler(UIElement.PointerReleasedEvent, new PointerEventHandler(Element_PointerCanceled), true);
//PointerReleased is never raised, then a PointerCanceled or PointerCaptureLos
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}