Invalid tooltip culture
I have xaml:
<TextBlock Text="{local:Bind Test}" ToolTip="{local:Bind Test}" /> And here is a screenshot (using a magnifying glass):
My question is: what is going on here? Why does the tooltip show the value in different ways (decimal point . While expected)?
Longer:
I am trying to display numbers in the same format as in the user settings of the Windows number format.
To do this, I redefine the language before displaying the window (overriding App.OnStartup):
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); And using the following custom binding (to set the default converter culture)
public class Bind : Binding { public Bind(string path) : base(path) { ConverterCulture = CultureInfo.CurrentCulture; } } It works for the Text TextBox property, but it does not work for ToolTip .
To see what I show in the screenshot:
- go (Windows 7)
Control Panel/Region and Language/Formatsand set theFormatasEnglish (United States) - go
Additional settings/Numbersand change theDecimal symbolfrom.before - create a new wpf application, copy xaml, add a language override, add a converter and install:
public partial class MainWindow : Window { public double Test { get; set; } = 1.234567; public MainWindow() { InitializeComponent(); DataContext = this; } } I am also facing the same problem. Thus, you can solve this problem by adding a TextBlock inside the ToolTip and linking the same Text="{local:Bind Test}" for this TextBlock ToolTip.
<TextBlock> <TextBlock.ToolTip> <TextBlock Text="{local:Bind Test}"/> </TextBlock.ToolTip> </TextBlock> 