-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
In my current scenario the Zoombox control contains other custom user-controls that support drag&drop and other mouse-related features.
Therefore, I'd appreciate if the Zoombox activates it’s functionality only if e.g. the Control-key is pressed. The following code-snippet demonstrates my idea. OnMouseWheel also would need to respect ActivateOn accordingly..
What do you think of this idea?
public ModifierKeys ActivateOn
{
get { return (ModifierKeys)GetValue(ActivateOnProperty); }
set { SetValue(ActivateOnProperty, value); }
}
public static readonly DependencyProperty ActivateOnProperty = DependencyProperty.Register(nameof(ActivateOn), typeof(ModifierKeys), typeof(Zoombox), new PropertyMetadata(ModifierKeys.None));
/// <inheritdoc />
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
if (e is null)
{
throw new ArgumentNullException(nameof(e));
}
this.position = e.GetPosition(this);
if (ActivateOn == ModifierKeys.None || Keyboard.Modifiers.HasFlag(ActivateOn))
{
_ = this.CaptureMouse();
}
base.OnMouseLeftButtonDown(e);
}
Metadata
Metadata
Assignees
Labels
No labels