本文整理汇总了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);
}
示例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));
}
示例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
}
示例4: DragListener
public DragListener(FrameworkElement target)
{
this.target = target;
target.AddHandler(Mouse.MouseDownEvent, new MouseButtonEventHandler(MouseButtonDown), true);
target.PreviewMouseMove += MouseMove;
target.PreviewMouseLeftButtonUp += MouseLeftButtonUp;
}
示例5: SetOrientationProvider
public virtual void SetOrientationProvider(FrameworkElement control)
{
if (control != null)
{
CurrentControl = control;
control.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(HandleOwnerMouseRightButtonDown), true);
}
}
示例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;
}
示例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);
}
示例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;
}
示例9: EnterAction
public void EnterAction(FrameworkElement target, BaseValueSource valueSource)
{
target.AddHandler(Event, Handler, HandledEventsToo);
}
示例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);
}
}
示例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);
}
示例12: InitializeCore
protected override void InitializeCore(FrameworkElement source)
{
source.AddHandler(RoutedEvent, (RoutedEventHandler)ExecuteCommand);
}
示例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);
}
示例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);
}