Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public class TextboxTrimSpaceing : TextBox
  2. {
  3.  
  4. private string myVar;
  5.  
  6. new public string Text
  7. {
  8. get { return myVar; }
  9. set { myVar = value.TrimEnd().TrimStart(); }//Control is not cmg here
  10. }
  11.  
  12. }
  13.  
  14. <local:TextboxTrimSpaceing x:Name="TrimSpaceing" Text=" avi aaa "></local:TextboxTrimSpaceing>
  15.  
  16. var i = TrimSpaceing.Text; //Getting Null
  17.  
  18. public class TextboxTrimSpacing : TextBox
  19. {
  20. private bool _trim = true;
  21. protected override void OnTextChanged(TextChangedEventArgs e)
  22. {
  23. base.OnTextChanged(e);
  24. if(_trim)
  25. {
  26. _trim = false;
  27. Text = Text?.Trim();
  28. _trim = true;
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement