c# - How to accepting negative floating numbers with TextBox UWP? -


i have requirement.

1) accept positive , negative floating numbers

2) accept numbers values represent latitude,longitude coordinates.

from answers posted got how accept positive floating numbers

private void floattextbox_textchanging(textbox sender, textboxtextchangingeventargs args) {     try     {         if (!regex.ismatch(sender.text, "^\\d*\\.?\\d*$") && sender.text != "")         {             int pos = sender.selectionstart - 1;             sender.text = sender.text.remove(pos, 1);             sender.selectionstart = pos;         }     }     catch     {     } } 

i wanted know how accept negative numbers adding ^\- beginning of expression not working. tried other answers here none worked coordinates.

try 1

@"^[-]?[0-9]*(?:\.[0-9]*)?$" 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -