I have in xaml:
<TextBlock Text="{local:Bind Test}" ToolTip="{local:Bind Test}" />
And here is screenshot (using magnifier):
My question is what is going on here? Why tooltip displays value differently (decimal point is .
while ,
is expected)?
Longer story:
I am trying to display numbers in same format as in user Windows number format preferences.
For this I've override the language before displaying window (overriding App.OnStartup):
FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
And using following custom binding (to set converter culture by default)
public class Bind : Binding
{
public Bind(string path) : base(path)
{
ConverterCulture = CultureInfo.CurrentCulture;
}
}
It works for Text
property of TextBox
, but it doesn't work for ToolTip
.
To actually see what I show on screenshot:
Control Panel/Region and Language/Formats
and set Format
as English (United States)
Additional settings/Numbers
and change Decimal symbol
from .
to ,
public partial class MainWindow : Window
{
public double Test { get; set; } = 1.234567;
public MainWindow()
{
InitializeComponent();
DataContext = this;
}
}
I'm also facing the same problem. So you can resolve this by adding TextBlock
inside the ToolTip
and bind the same Text="{local:Bind Test}"
for this ToolTip's TextBlock also.
<TextBlock>
<TextBlock.ToolTip>
<TextBlock Text="{local:Bind Test}"/>
</TextBlock.ToolTip>
</TextBlock>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With