DataGridTextColumn doesn't allow to enter “dou

2019-07-16 09:39发布

问题:

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.