简体   繁体   English

如何在WPF中表示基点

[英]How can I represent basis points in WPF

I have a DevExpress dxe:TextEdit control with EditValueType="{x:Type system:Decimal}" . 我有一个具有EditValueType="{x:Type system:Decimal}"的DevExpress dxe:TextEdit控件。 I would like this TextEdit control to display and accept values that are 10,000 times the actual value. 我希望此TextEdit控件显示并接受实际值的10,000倍的值。 Eg, if someone enters 15, it should save the actual value as .0015. 例如,如果有人输入15,则应将实际值保存为.0015。 And if the value in the viewmodel is .0015, it should display 15. 并且如果viewmodel中的值为.0015,则应显示15。

I am new to WPF and I am not sure the best way to accomplish this. 我是WPF的新手,我不确定实现此目标的最佳方法。 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. 我之前曾与DevExpress合作。

As far as I can remember, you can create your own TextEdit class. 据我所记得,您可以创建自己的TextEdit类。 (Derive from TextEditBase or even go further and derive from BaseEdit). (从TextEditBase派生,甚至可以从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. 我将使用get / set函数来完成此任务。 Perfect way of using them to translate presentation format to/from storage format. 使用它们将演示文稿格式转换为存储格式的完美方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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