Following is the property that can be bind to text box, and handles the text box to enter only integer values, and converting to positive Integer value if any negative Integer value will entered in text box.
private String strPageSize = ""; public String PageSize { get { return strPageSize; set { Regex myRange = new Regex(@"^-{0,1}\d+$"); if (!myRange.IsMatch(value)) { throw new Exception("Numbers are allowed only"); } strPageSize = (Math.Abs(Convert.ToDecimal(value))).ToString(); RaisePropertyChanged("PageSize"); } }
No comments:
Post a Comment