DataGridTextColumn doesn't allow to enter “double” value

僤鯓⒐⒋嵵緔 提交于 2019-12-11 03:56:54

问题


I have property double? MyDouble { get .. set ... }. I've binded it in DataGridTextColumn:

<DataGridTextColumn Binding="{Binding MyDouble}" />

It works fine unless I add UpdateSourceTrigger=PropertyChanged.

<DataGridTextColumn Binding="{Binding MyDouble, 
                              UpdateSourceTrigger=PropertyChanged}" />

In this case I can't enter "." and add "double" value. How can I avoid this behavior?


回答1:


Uninstall .NET 4.5 Beta. I've posted this bug to Microsoft support.




回答2:


I think this is related to your windows localization settings. For example if you want to convert "1,65" under US localized windows to double, exception will be thrown. But when you want to convert the same string under Czech localization, it will proceed.

Is it really working without UpdateSourceTrigger set to PropertyChanged? I think it would just allow you to enter the "." but binding won't set the value to underlying context.




回答3:


For those who havent found out any other solution i also found this:

The data type allows you to select what data type it is and chances are is that yours is set to int32.



来源:https://stackoverflow.com/questions/9805539/datagridtextcolumn-doesnt-allow-to-enter-double-value

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