简体   繁体   中英

How can I represent basis points in WPF

I have a DevExpress dxe:TextEdit control with EditValueType="{x:Type system:Decimal}" . I would like this TextEdit control to display and accept values that are 10,000 times the actual value. Eg, if someone enters 15, it should save the actual value as .0015. And if the value in the viewmodel is .0015, it should display 15.

I am new to WPF and I am not sure the best way to accomplish this. It seems like I can't do it with format strings, but I could be wrong. A value converter seems like overkill. I also thought about modifying the setter on my model object, but I don't think that would work, and it seems sort of hack-y.

I've worked with DevExpress a while ago.

As far as I can remember, you can create your own TextEdit class. (Derive from TextEditBase or even go further and derive from BaseEdit).

However, talking about over-killing, I think this is a much greater over-kill than just creating a converter, which will be a really good solution IMHO.

I would use the get/set functions to accomplish this. Perfect way of using them to translate presentation format to/from storage format.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM