当前位置: 首页>>代码示例>>C#>>正文


C# UIElement.AddHandler方法代码示例

本文整理汇总了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;
        }
开发者ID:Kinnara,项目名称:KinnaraToolkit,代码行数:18,代码来源:HoldListener.cs

示例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());
            }
        }
开发者ID:gsantopaolo,项目名称:MPCExtensions,代码行数:34,代码来源:InkToTextCanvas.cs


注:本文中的Windows.UI.Xaml.UIElement.AddHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。