dotnet / dotnet/wpf

Editable ComboBox shows wrong decimal separator for selected item

Open
#2,349 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 3.1 and 3.0
* Windows version: 10 - 1909 (but should be independant)
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No


**Problem description:**
ComboBox when set to IsEditable="True" shows decimal separator of system language for selected value in textbox when bound to double values instead of the one set via the XAML Language property or even the UICulture set in code. If you also bind the Text property of the ComboBox to a double value the decimal separator is completely dropped (eg. making "2.3" to "23") which also only happens if the decimal separator is different between selected and system culture.

**Actual behavior:**
My windows culture is set to German and I set the Language property of the window to "en" and the double values in the dropdown correctly show the . as decimal separator. But if I select a value it shows the decimal separator in the textbox of the editable ComboBox. (A TextBox bound to the same selected item does show the right decimal separator)

**Expected behavior:**
A selected bound double value in a editable ComboBox picks up the same language as every other control in WPF set by the language property.

**Minimal repro:**
1) Set windows culture to German.
2) Create a ComboBox in XAML and bind it's ItemsSource to a collection of double values.
3) Set IsEditable="True" on the ComboBox
3) Change the Language property of the window to a culture that uses the dot (.) as decimal separator (e.g. English) (Language="en")
4) If you now select a value from the dropdown it is shown with the comma as decimal separator int the ComboBox textbox.
5) If you now add a binding of a double property to the Text property of the ComboBox the value is shown without decimal separator

Minimum reproducable project can be found here: https://github.com/Mrxx99/WpfComboBoxCultureIssue

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.