UWP : CustomEditControl - "Order" unable to send back

Indudhar Gowda 426 Reputation points
2020-04-12T08:45:18.56+00:00

UWP : CustomEditControl - "Order" unable to send back .

I have 2 Controls Overlaying one above another but Order bring to front or back not working.

I have attached the GIF file with attached dummy project. 7401-customeditcontrolorder.gif

s!Ag8QU6ar3yRugYlB7Oe2lT1INlkMKg

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Fay Wang - MSFT 5,191 Reputation points
    2020-04-13T02:33:24.26+00:00

    Hello,

    Welcome to Microsoft Q&A!

    CUSTOM EDIT CONTROL - NOT WORKING

    By checking your sample, the customer_edit_control still responds is because you subscribe the PointerPressed event of CoreWindow in CustomEditControl.xaml.cs, when you click on screen, this event will be triggered. So even if you only click the Button, this event still be triggered and then set the focus to your control.

    You can add a property to judge if the mouse is in your CustomEditControl, if it is, you can perform operations in the PointerPressed event of CoreWindow. For example:

    private bool isBeyondScope = false;
    
    BorderPanel.PointerEntered += fdgdfgd;
    BorderPanel.PointerExited += fdgdfgd1;
    
    
    private void fdgdfgd1(object sender, PointerRoutedEventArgs e)
    {
        Window.Current.CoreWindow.PointerCursor = cursorBeforePointerEntered;
        isBeyondScope = true;
    }
    
    private void fdgdfgd(object sender, PointerRoutedEventArgs e)
    {
        isBeyondScope = false;
        buttonCursor = new CoreCursor(CoreCursorType.IBeam, 5);
        cursorBeforePointerEntered = Window.Current.CoreWindow.PointerCursor;
        // Set button cursor.
        Window.Current.CoreWindow.PointerCursor = buttonCursor;
    }
    
    void CoreWindow_PointerPressed(CoreWindow sender, PointerEventArgs args)
    {
        Rect contentRect = GetElementRect(BorderPanel);
        if (contentRect.Contains(args.CurrentPoint.Position) && isBeyondScope == false)
        {
            var mm = GetElementRect(ClearButton);
            if (mm.Contains(args.CurrentPoint.Position))
           {
               Text = string.Empty;
               var range = Selection;
               SetSelectionAndNotify(range);
               args.Handled = true;
               return;
           }
          UpdateTargetBoxID?.Invoke(uniqueKey, Type);
          if (IsReadOnly || !IsEnabled) return;
          SetInternalFocus(uniqueKey);
          Focus(FocusState.Programmatic);
        }
        else
        {
        // The user tapped outside the control. Remove focus.
            if (!kbActive)
            {
                Selection.StartCaretPosition = Selection.EndCaretPosition = _text.Length;
                RemoveInternalFocus();
            }
            kbActive = false;
        }
     }
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful