WPF Edit Mask

2019-04-21 10:55发布

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.

3条回答
唯我独甜
2楼-- · 2019-04-21 11:53

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...

查看更多
做自己的国王
3楼-- · 2019-04-21 11:55

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/

查看更多
ゆ 、 Hurt°
4楼-- · 2019-04-21 12:01

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.

查看更多
登录 后发表回答