WPF Edit Mask

蓝咒 提交于 2019-12-22 04:07:15

问题


What is the easiest way to specify an edit mask in WPF for a simple Text Box?

e.g. one that transforms 10000 to 10,000 as you type.


回答1:


Short answer, there is no easy way. If you use masks quite often, I would recommend creating your own control with masking functionality. Using the MaskedTextProvider class should be fairly straightforward.

See the following for an example of a custom TextBox with masking capabilities:

Masked TextBox example...




回答2:


Easiest and most straightforward way is probably just to grab the TextChanged event and do whatever processing you need.

ex... http://karlhulme.wordpress.com/2007/02/15/masking-input-to-a-wpf-textbox/




回答3:


Have you looked at the Xceed DataGrid Express for WPF. It is free and provides a masked text box control that will very simply do what you want.

The xceed Datagrid Express edition for WPF is no longer available.



来源:https://stackoverflow.com/questions/534326/wpf-edit-mask

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!