本文整理汇总了C#中System.Windows.UIElement.AddHandler方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.AddHandler方法的具体用法?C# UIElement.AddHandler怎么用?C# UIElement.AddHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.UIElement
的用法示例。
在下文中一共展示了UIElement.AddHandler方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EngineHandlerBase
/// <summary>
/// Initializes a new instance of the <see cref="EngineHandler"/> class.
/// </summary>
/// <param name="engineCreator">The function used to create an instance of the engine that actually recognizes the gesture.</param>
/// <param name="trackedElement">The tracked element.</param>
/// <param name="handleTouchEvent">if set to <c>true</c> then all touch events occurring on the tracked element will get e.Handled set to true to avoid further routing of the events.</param>
public EngineHandlerBase(Func<IGestureEngine> engineCreator, UIElement trackedElement, bool handleTouchEvent = false)
{
this._engineCreator = engineCreator;
this._trackedElement = trackedElement;
this.HandlesTouchEvents = handleTouchEvent;
trackedElement.AddHandler(UIElement.TouchDownEvent, new EventHandler<TouchEventArgs>(OnTrackedElementTouchDown), true);
trackedElement.AddHandler(UIElement.TouchUpEvent, new EventHandler<TouchEventArgs>(OnTrackedElementTouchUp), true);
trackedElement.AddHandler(UIElement.TouchMoveEvent, new EventHandler<TouchEventArgs>(OnTrackedElementTouchMove), true);
//trackedElement.AddHandler(UIElement.MouseDownEvent, new EventHandler<MouseButtonEventArgs>(OnTrackedElementMouseDown));
//trackedElement.AddHandler(UIElement.MouseUpEvent, new EventHandler<MouseButtonEventArgs>(OnTrackedElementMouseUp));
//trackedElement.AddHandler(UIElement.MouseMoveEvent, new EventHandler<MouseButtonEventArgs>(OnTrackedElementMouseMove));
}
示例2: RegisterEvent
/// <summary>
/// 注册事件
/// </summary>
/// <param name="element"></param>
public void RegisterEvent(UIElement element)
{
if (element != null)
{
element.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(ElementMouseDown), true);
}
}
示例3: AddPreviewExecutedHandler
/// <summary>
/// Attaches the handler on the element.
/// </summary>
/// <param name="element">The element on which to attach the handler.</param>
/// <param name="handler">The handler to attach.</param>
public static void AddPreviewExecutedHandler(UIElement element, ExecutedRoutedEventHandler handler)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
if (handler == null)
{
throw new ArgumentNullException("handler");
}
element.AddHandler(PreviewExecutedEvent, handler);
}
示例4: CaptureThief
// Methods
public CaptureThief(UIElement element)
{
this.Owner = element;
SetHasCaptureThief(this.Owner, true);
element.AddHandler(UIElement.GotMouseCaptureEvent, new MouseEventHandler(this.OnGotMouseCapture), true);
element.AddHandler(UIElement.GotTouchCaptureEvent, new EventHandler<TouchEventArgs>(this.OnGotTouchCapture), true);
element.AddHandler(UIElement.MouseMoveEvent, new MouseEventHandler(this.OnMouseMove), true);
element.AddHandler(UIElement.TouchMoveEvent, new EventHandler<TouchEventArgs>(this.OnTouchMove), true);
element.AddHandler(UIElement.LostMouseCaptureEvent, new MouseEventHandler(this.OnLostMouseCapture), true);
element.AddHandler(UIElement.LostTouchCaptureEvent, new EventHandler<TouchEventArgs>(this.OnLostTouchCapture), true);
}
示例5: HexMouseProcessorCollection
public HexMouseProcessorCollection(UIElement mouseElement, UIElement manipulationElement, DefaultHexMouseProcessor defaultMouseProcessor, HexMouseProcessor[] mouseProcessors, Func<MouseEventArgs, bool> allowEvent) {
if (mouseElement == null)
throw new ArgumentNullException(nameof(mouseElement));
if (defaultMouseProcessor == null)
throw new ArgumentNullException(nameof(defaultMouseProcessor));
if (mouseProcessors == null)
throw new ArgumentNullException(nameof(mouseProcessors));
this.mouseElement = mouseElement;
this.manipulationElement = manipulationElement;
this.defaultMouseProcessor = defaultMouseProcessor;
this.mouseProcessors = mouseProcessors;
this.allowEvent = allowEvent ?? defaultAllowEvent;
mouseElement.AddHandler(UIElement.QueryContinueDragEvent, new QueryContinueDragEventHandler(MouseElement_QueryContinueDrag), true);
mouseElement.AddHandler(UIElement.MouseWheelEvent, new MouseWheelEventHandler(MouseElement_MouseWheel), true);
mouseElement.AddHandler(UIElement.MouseUpEvent, new MouseButtonEventHandler(MouseElement_MouseUp), true);
mouseElement.AddHandler(UIElement.MouseRightButtonUpEvent, new MouseButtonEventHandler(MouseElement_MouseRightButtonUp), true);
mouseElement.AddHandler(UIElement.MouseRightButtonDownEvent, new MouseButtonEventHandler(MouseElement_MouseRightButtonDown), true);
mouseElement.AddHandler(UIElement.MouseMoveEvent, new MouseEventHandler(MouseElement_MouseMove), true);
mouseElement.AddHandler(UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler(MouseElement_MouseLeftButtonUp), true);
mouseElement.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(MouseElement_MouseLeftButtonDown), true);
mouseElement.AddHandler(UIElement.MouseLeaveEvent, new MouseEventHandler(MouseElement_MouseLeave), true);
mouseElement.AddHandler(UIElement.MouseEnterEvent, new MouseEventHandler(MouseElement_MouseEnter), true);
mouseElement.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(MouseElement_MouseDown), true);
mouseElement.AddHandler(UIElement.GiveFeedbackEvent, new GiveFeedbackEventHandler(MouseElement_GiveFeedback), true);
mouseElement.AddHandler(UIElement.DropEvent, new DragEventHandler(MouseElement_Drop), true);
mouseElement.AddHandler(UIElement.DragOverEvent, new DragEventHandler(MouseElement_DragOver), true);
mouseElement.AddHandler(UIElement.DragLeaveEvent, new DragEventHandler(MouseElement_DragLeave), true);
mouseElement.AddHandler(UIElement.DragEnterEvent, new DragEventHandler(MouseElement_DragEnter), true);
if (manipulationElement != null) {
manipulationElement.AddHandler(UIElement.TouchUpEvent, new EventHandler<TouchEventArgs>(ManipulationElement_TouchUp), true);
manipulationElement.AddHandler(UIElement.TouchDownEvent, new EventHandler<TouchEventArgs>(ManipulationElement_TouchDown), true);
manipulationElement.AddHandler(UIElement.StylusSystemGestureEvent, new StylusSystemGestureEventHandler(ManipulationElement_StylusSystemGesture), true);
manipulationElement.AddHandler(UIElement.ManipulationStartingEvent, new EventHandler<ManipulationStartingEventArgs>(ManipulationElement_ManipulationStarting), true);
manipulationElement.AddHandler(UIElement.ManipulationInertiaStartingEvent, new EventHandler<ManipulationInertiaStartingEventArgs>(ManipulationElement_ManipulationInertiaStarting), true);
manipulationElement.AddHandler(UIElement.ManipulationDeltaEvent, new EventHandler<ManipulationDeltaEventArgs>(ManipulationElement_ManipulationDelta), true);
manipulationElement.AddHandler(UIElement.ManipulationCompletedEvent, new EventHandler<ManipulationCompletedEventArgs>(ManipulationElement_ManipulationCompleted), true);
}
}
示例6: AddQueryInteractionStatusHandler
/// <summary>
/// Adds a handler for the QueryGripInteractionStatus attached event
/// </summary>
/// <param name="element">UIElement that listens to this event</param>
/// <param name="handler">Event Handler to be added</param>
public static void AddQueryInteractionStatusHandler(UIElement element, EventHandler<QueryInteractionStatusEventArgs> handler)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.AddHandler(KinectRegion.QueryInteractionStatusEvent, handler);
}
示例7: AddHandPointerLostCaptureHandler
/// <summary>
/// Adds a handler for the HandPointerLostCapture attached event
/// </summary>
/// <param name="element">UIElement that listens to this event</param>
/// <param name="handler">Event Handler to be added</param>
public static void AddHandPointerLostCaptureHandler(UIElement element, EventHandler<HandPointerEventArgs> handler)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.AddHandler(KinectRegion.HandPointerLostCaptureEvent, handler);
}
示例8: Relay
public static void Relay(UIElement element)
{
element.AddHandler(CommandManager.ExecutedEvent, new RoutedEventHandler(HandleExecute), true);
element.AddHandler(CommandManager.CanExecuteEvent, new RoutedEventHandler(HandleCanExecute), true);
element.AddHandler(CommandManager.PreviewExecutedEvent, new RoutedEventHandler(HandlePreviewExecute), true);
element.AddHandler(CommandManager.PreviewCanExecuteEvent, new RoutedEventHandler(HandlePreviewCanExecute), true);
}
示例9: AddClearPropertyItemHandler
/// <summary>
/// Adds a handler for the ClearPropertyItem attached event
/// </summary>
/// <param name="element">the element to attach the handler</param>
/// <param name="handler">the handler for the event</param>
public static void AddClearPropertyItemHandler( UIElement element, PropertyItemEventHandler handler )
{
element.AddHandler( PropertyGrid.ClearPropertyItemEvent, handler );
}
示例10: AddPreparePropertyItemHandler
/// <summary>
/// Adds a handler for the PreparePropertyItem attached event
/// </summary>
/// <param name="element">the element to attach the handler</param>
/// <param name="handler">the handler for the event</param>
public static void AddPreparePropertyItemHandler( UIElement element, PropertyItemEventHandler handler )
{
element.AddHandler( PropertyGrid.PreparePropertyItemEvent, handler );
}
示例11: AddCanExecuteHandler
/// <summary>
/// Attaches the handler on the element.
/// </summary>
/// <param name="element">The element on which to attach the handler.</param>
/// <param name="handler">The handler to attach.</param>
public static void AddCanExecuteHandler(UIElement element, CanExecuteRoutedEventHandler handler)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
if (handler == null)
{
throw new ArgumentNullException("handler");
}
element.AddHandler(CanExecuteEvent, handler);
}
示例12: PairExpanded
public static void PairExpanded(this TreeViewItem item, UIElement pairToObject, RoutedEvent pairToExpandEvent, RoutedEvent pairToCollapseEvent, DependencyProperty pairToProperty)
{
item.AddSelfExpanded((sender, args) => pairToObject.SetValue(pairToProperty, true));
item.AddSelfCollapsed((sender, args) => pairToObject.SetValue(pairToProperty, false));
pairToObject.SetValue(pairToProperty, item.IsExpanded);
pairToObject.AddHandler(pairToExpandEvent, new RoutedEventHandler((sender, args) => item.IsExpanded = true));
pairToObject.AddHandler(pairToCollapseEvent, new RoutedEventHandler((sender, args) => item.IsExpanded = false));
}