DataGridTextColumn doesn't allow to enter “dou

2019-07-16 09:29发布

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?

3条回答
来,给爷笑一个
2楼-- · 2019-07-16 09:34

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楼-- · 2019-07-16 09:37

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

Screenshot

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

查看更多
甜甜的少女心
4楼-- · 2019-07-16 09:59

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

查看更多
登录 后发表回答