bodong1987 / Avalonia.PropertyGrid

A property edit control in Avalonia like DevExpress's PropertyGridControl.
https://www.cnblogs.com/bodong
MIT License
187 stars 18 forks source link

Double and Float are not correctly converted #44

Open FCUnlimited opened 1 week ago

FCUnlimited commented 1 week ago

Hi,

first of all thanks for your work. Works great so far.

Found only one issue: If I have got a double or float property and enter a value like 0,5 it gets converted to 5.

I have the same problem in the samples-Basic project. Maybe it has something to do with the local used language? In this case it is DE.

Are you able to reproduce the issue in the sample project? Thanks in advanced!

BugPropertyGrid

bodong1987 commented 1 week ago

It really should have something to do with localization. But the exception in your screenshot looks like it was thrown by Avalonia. The source code of CellEditor about numerical values ​​is at: main/Avalonia.PropertyGrid/Controls/Factories/Builtins/NumericCellEditFactory.cs In my local language environment, Avalonia's control returns 5 when I input 0,5. Theoretically, Avalonia should use the system's localization configuration by default to initialize the NumberFormat property of the control. So you can try setting the NumberFormat property of NumericUpDown directly. You can also provide your own NumericCellEditFactory through expansion, change its ImportPriority to a larger value, and then provide it to the PropertyGrid. Extension method: main/Samples/Avalonia.PropertyGrid.Samples/Views/TestExtendPropertyGrid.cs

FCUnlimited commented 2 days ago

Thanks for your response. I checked the code and it looks like it's not the localization (or not only). The error occures during the transformation from float input to double as you can see in the first red marked part: grafik

The double input conversion works in the first part but crashes during string conversion. So I added the culture info also in the tryparse method which looks like it is working now.