You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
}
The text was updated successfully, but these errors were encountered:
About the idea I agree it is a solution but it does not feel very idiomatic and discoverable. Feels more like an ad-hoc solution that would be a better fit in application code.
Are there any other/better solutions than subclassing or modifier-keys?
Maybe events Zooming and Dragging where you can set e.Enabled = ...my condition... ? It provides more flexibility, but it is better idiomatic/discoverable?
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?
The text was updated successfully, but these errors were encountered: