question

IDGO-6443 avatar image
0 Votes"
IDGO-6443 asked ·

UWP : CustomEditControl - "Order" unable to send back

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


windows-uwpwindows-uwp-xaml
· 1
10 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

FayWang-MSFT avatar image
1 Vote"
FayWang-MSFT answered ·

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;
     }
  }

· 7
10 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks FayWang-MSFT Its Working...Can u please suggest on textBox.ScrollToCaret(); not working...

0 Votes 0 ·

If you want to scroll to the bottom of textBox, first you can get the built-in ScrollViewer from the textBox and then use ChangeView method of ScrollViewer to scroll to the buttom.

1 Vote 1 ·

thanks...its working...

0 Votes 0 ·
Show more comments