private void ClearPressedState(PointerRoutedEventArgs routedArgs) { if (_pressedElements.TryGetValue(routedArgs.Pointer, out var pressedLeaf)) { // We must make sure to clear the pressed state on all elements that was flagged as pressed. // This is required as the current originalSource might not be the same as when we pressed (pointer moved), // ** OR ** the pointer has been captured by a parent element so we didn't raised to released on the sub elements. _pressedElements.Remove(routedArgs.Pointer); // Note: The event is propagated silently (public events won't be raised) as it's only to clear internal state var ctx = new BubblingContext { IsInternal = true }; pressedLeaf.OnPointerUp(routedArgs, ctx); } }
private static void Raise(RaisePointerEventArgs raise, VisualTreeHelper.Branch branch, PointerRoutedEventArgs routedArgs) => raise(branch.Leaf, routedArgs, BubblingContext.BubbleUpTo(branch.Root));