C # NOTE11:WPF maskable TextBox for Numeric Values

Source: Internet
Author: User

This article describes what to enhance the WPF and make TextBox it accept just numeric (integers and floating point) values. T He second goal is make the TextBox smart enough to make it easier to input numerics. This TextBox is a easy means to provide the with some kind of intelligence, not just rejecting non-numeric symbols. The provided extension also allows setting minimum and/or maximum values.

If you search on the net, you'll probably find some solutions for this problem where developers create their own vers Ions of the  TextBox  either by inheriting from it or creating a custom/user Controls that include th e standard wpf  TextBox . Most other solutions has one major drawback-you would need to replace your  TextBox definitions with yo ur new  masktextbox . Sometimes, it is isn't painful, sometimes, it is. The reason I chose another solution is and the my case, such kind of changes would was painful.

The approach I ' m proposing here's the usage of WPF attached Properties, which basically is similar to Dependency Propert ies. The major difference among these to be that Dependency properties were defined inside the control, but attached properties is defined outside. For instance, was TextBox.Text a Dependency property, but was an Grid.Column attached property.

Https://www.codeproject.com/Articles/34228/WPF-Maskable-TextBox-for-Numeric-Values

Simple Numeric Textbox:https://www.codeproject.com/articles/30812/simple-numeric-textbox

C # NOTE11:WPF maskable TextBox for Numeric Values

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.