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


C# FrameworkElement.AddHandler方法代码示例

本文整理汇总了C#中System.Windows.FrameworkElement.AddHandler方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.AddHandler方法的具体用法?C# FrameworkElement.AddHandler怎么用?C# FrameworkElement.AddHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.FrameworkElement的用法示例。


在下文中一共展示了FrameworkElement.AddHandler方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttachCommandHandlers

        public void AttachCommandHandlers(FrameworkElement sender)
        {
            sender.AddHandler(CommandManager.PreviewCanExecuteEvent, new CanExecuteRoutedEventHandler(PreviewCanExecuteHandler), true);
              sender.AddHandler(CommandManager.CanExecuteEvent, new CanExecuteRoutedEventHandler(CanExecuteHandler), true);

              sender.AddHandler(CommandManager.PreviewExecutedEvent, new ExecutedRoutedEventHandler(PreviewExecutedHandler), true);
              sender.AddHandler(CommandManager.ExecutedEvent, new ExecutedRoutedEventHandler(ExecutedHandler), true);
        }
开发者ID:B3nCr,项目名称:wpf-notifyicon,代码行数:8,代码来源:CommandRerouter.cs

示例2: MouseClickWrapper

		/// <summary>
		/// Initializes a new instance of the <see cref="MouseClickWrapper"/> class with specified FrameworkElement as mouse events source and specified MouseButton 
		/// to notify about its clicks.
		/// </summary>
		/// <param name="element">The element.</param>
		/// <param name="mouseButton">The mouse button.</param>
		public MouseClickWrapper(FrameworkElement element, MouseButton mouseButton)
		{
			if (element == null)
				throw new ArgumentNullException("element");

			this.element = element;
			this.mouseButton = mouseButton;

			element.AddHandler(FrameworkElement.MouseDownEvent, new MouseButtonEventHandler(OnMouseDown));
			element.AddHandler(FrameworkElement.MouseUpEvent, new MouseButtonEventHandler(OnMouseUp));
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:17,代码来源:MouseClickService.cs

示例3: AddWidget

        /// <summary>
        /// Add an element
        /// </summary>
        /// <param name="element"></param>
        public void AddWidget(FrameworkElement element)
        {
            element.Cursor = Cursors.SizeAll;
            element.AddHandler(FrameworkElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(MouseLeftButtonDown), true);
            element.AddHandler(FrameworkElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler(MouseLeftButtonUp), true);
            element.AddHandler(FrameworkElement.MouseMoveEvent, new MouseEventHandler(MouseMove), true);

            ResizingAdorner adorner = element.IsActivity() ? new ScaleResizingAdorner(element) : new ResizingAdorner(element);
            adorner.WidgetDragging += OnWidgetDragging;
            adornerLayer.Add(adorner);

            elements.Add(element, adorner);
            ElementsRightBottom.Add(element, new Point()); // element may has not loaded
        }
开发者ID:barbarossia,项目名称:CWF,代码行数:18,代码来源:DraggingWidgetHelper.cs

示例4: DragListener

		public DragListener(FrameworkElement target)
		{
			this.target = target;
			target.AddHandler(Mouse.MouseDownEvent, new MouseButtonEventHandler(MouseButtonDown), true);
			target.PreviewMouseMove += MouseMove;
			target.PreviewMouseLeftButtonUp += MouseLeftButtonUp;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:7,代码来源:DragListener.cs

示例5: SetOrientationProvider

 public virtual void SetOrientationProvider(FrameworkElement control)
 {
     if (control != null)
     {
         CurrentControl = control;
         control.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(HandleOwnerMouseRightButtonDown), true);
     }
 }
开发者ID:SaintLoong,项目名称:PD,代码行数:8,代码来源:ControlOrientationProvider.cs

示例6: InstallScale

		public void InstallScale(FrameworkElement elem) {
			UninstallScale();
			scaleElement = elem;
			if (scaleElement == null)
				return;
			// A scrollviewer will prevent our code from getting called so use AddHandler()
			scaleElement.AddHandler(UIElement.MouseWheelEvent, new MouseWheelEventHandler(ScaleElement_MouseWheel), true);
			scaleElement.CommandBindings.AddRange(commandBindings);
			scaleElement.InputBindings.AddRange(keyBindings);
			ScaleValue = ScaleValue;
		}
开发者ID:levisre,项目名称:dnSpy,代码行数:11,代码来源:TabElementScaler.cs

示例7: AttachOneShotCommandHandler

        public static void AttachOneShotCommandHandler(FrameworkElement element, RoutedEvent @event, RoutedEventHandler callback)
        {
            RoutedEventHandler handler = null;
              handler = (arg0, arg1) =>
              {
            element.RemoveHandler(@event, handler);

            callback(arg0, arg1);
              };

              element.AddHandler(@event, handler);
        }
开发者ID:B3nCr,项目名称:wpf-notifyicon,代码行数:12,代码来源:CommandRerouter.cs

示例8: DragHelper

        /// <summary>
        /// Initializing constructor
        /// </summary>
        /// <param name="dragSource">Element to be the source of a drag operation</param>
        public DragHelper( FrameworkElement dragSource )
        {
            _dragSource = dragSource;

            _dragSource.AddHandler( FrameworkElement.MouseLeftButtonDownEvent,
                                    new MouseButtonEventHandler( OnMouseLeftButtonDown ), true );
            _dragSource.AddHandler( FrameworkElement.MouseLeftButtonUpEvent,
                                    new MouseButtonEventHandler( OnMouseLeftButtonUp ), true );
            _dragSource.AddHandler( FrameworkElement.MouseMoveEvent,
                                    new MouseEventHandler( OnMouseMove ), true );

            _dragSource.GiveFeedback += OnGiveFeedback;
        }
开发者ID:dxm007,项目名称:Droppy,代码行数:17,代码来源:DragDropHelper.cs

示例9: EnterAction

 public void EnterAction(FrameworkElement target, BaseValueSource valueSource)
 {
     target.AddHandler(Event, Handler, HandledEventsToo);
 }
开发者ID:diab0l,项目名称:Granular,代码行数:4,代码来源:EventSetter.cs

示例10: SetRootVisual

        /// <summary>
        ///     The set root visual.
        /// </summary>
        private static void SetRootVisual()
        {
            lock (Locker)
            {
                if ((RootVisual != null) || (Application.Current == null))
                {
                    return;
                }

#if (SILVERLIGHT)
                RootVisual = Application.Current.RootVisual as FrameworkElement;
#else
                RootVisual = BrowserInteropHelper.IsBrowserHosted ? null :
                    (Application.Current.MainWindow.Content as FrameworkElement) != null ? 
                    Application.Current.MainWindow.Content as FrameworkElement: Application.Current.MainWindow;
#endif
                if (RootVisual == null)
                {
                    return;
                }

                RootVisual.MouseMove += OnRootVisualMouseMove;
                RootVisual.AddHandler(
                    UIElement.MouseLeftButtonDownEvent, 
                    new MouseButtonEventHandler(OnRootVisualMouseLeftButtonDown), 
                    true);
            }
        }
开发者ID:bbbnova,项目名称:Orc.Toolkit,代码行数:31,代码来源:PinnableTooltipService.cs

示例11: ToggleFocusHandler

 protected virtual void ToggleFocusHandler()
 {
     _focusElement = GetFocusElement(_adornedElement);
     if (_visibleOnFocus && !_focusHandlerAdded)
     {
         _focusElement.AddHandler(FrameworkElement.GotFocusEvent, new RoutedEventHandler(OnGotFocus));
         _focusElement.AddHandler(FrameworkElement.LostFocusEvent, new RoutedEventHandler(OnLostFocus));
         _focusHandlerAdded = true;
     }
     else if (!_visibleOnFocus && _focusHandlerAdded)
     {
         _focusElement.RemoveHandler(FrameworkElement.GotFocusEvent, new RoutedEventHandler(OnGotFocus));
         _focusElement.RemoveHandler(FrameworkElement.LostFocusEvent, new RoutedEventHandler(OnLostFocus));
         _focusHandlerAdded = false;
     }
     if (_visibleOnFocus == false && _visible == false)
         this.Visibility = Visibility.Collapsed;
     else if (_visibleOnFocus == false && _visible == true)
         this.Visibility = Visibility.Visible;
     else
         this.Visibility = (_adornedElement.IsFocused) ? Visibility.Visible : ((_visibleOnFocus) ? Visibility.Collapsed : Visibility.Visible);
 }
开发者ID:HaKDMoDz,项目名称:eStd,代码行数:22,代码来源:GenericAdorner.cs

示例12: InitializeCore

		protected override void InitializeCore(FrameworkElement source)
		{
			source.AddHandler(RoutedEvent, (RoutedEventHandler)ExecuteCommand);
		}
开发者ID:T1Easyware,项目名称:Soheil,代码行数:4,代码来源:EventCommandTrigger.cs

示例13: AddReorderCompletedHandler

 /// <summary>
 /// Adds the reorder completed handler.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="handler">The handler.</param>
 public static void AddReorderCompletedHandler(FrameworkElement element,
                                               RoutedPropertyChangedEventHandler<int> handler)
 {
     element.AddHandler(ReorderCompletedEvent, handler);
 }
开发者ID:newHopeLJP,项目名称:WPFContrib,代码行数:10,代码来源:ListItemMoveBehavior.cs

示例14: SetRootVisual

        private static void SetRootVisual()
        {
            if ((rootVisual != null) || (Application.Current == null))
            {
                return;
            }

            rootVisual = Application.Current.RootVisual as FrameworkElement;
            if (rootVisual == null)
            {
                return;
            }

            rootVisual.MouseMove += OnRootVisualMouseMove;
            rootVisual.SizeChanged += OnRootVisualSizeChanged;
            rootVisual.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnRootVisualMouseLeftButtonDown), true);
        }
开发者ID:barrett2474,项目名称:CMS2,代码行数:17,代码来源:ToolTipService.cs


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