提示文化是错的 [英] Tooltip culture is wrong

查看:132
本文介绍了提示文化是错的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在XAML:

 < TextBlock的文本={本地:绑定测试}工具提示={本地:绑定测试}/> 

和这里的截图(用放大镜):





我的问题是什么是怎么回事?为什么提示显示值不同(小数点,而预计)?






长的故事:



我试图在用户的Windows数字显示在同一个格式的数字。格式偏好



有关这一点,我已经展示窗口(覆盖App.OnStartup)前覆盖语言:

  FrameworkElement.LanguageProperty.OverrideMetadata(typeof运算(FrameworkElement的),
新FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

和使用下面的自定义绑定(用来设置默认的转换器培养)

 公共类绑定:绑定
{
公共绑定(字符串路径):基地(路径)
{
ConverterCulture = CultureInfo.CurrentCulture;
}
}



它适用于文本 文本框的属性,但它并不适用于工具提示工作



要真正看到了我展示的截图:




  • 去(Windows 7中)控制面板/区域和语言/格式并设置格式英语(美国)

  • 其他设置/数字和变更十进制符号

  • 创建新的WPF应用程序中复制XAML,加上语言覆盖加转换,并且设置:



 公共部分类主窗口:窗口
{
公众的双重考验{搞定;组; } = 1.234567;

公共主窗口()
{
的InitializeComponent();
的DataContext =这一点;
}
}


解决方案

我M也面临着同样的问题。所以,你可以通过添加解决这个的TextBlock 工具提示里面并绑定在同一个文本= {本地:绑定测试}。此工具提示的TextBlock中还

 < TextBlock的> 
< TextBlock.ToolTip>
< TextBlock的文本={本地:绑定测试}/>
< /TextBlock.ToolTip>
< / TextBlock的>


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:

  • go (Windows 7) Control Panel/Region and Language/Formats and set Format as English (United States)
  • go Additional settings/Numbers and change Decimal symbol from . to ,
  • create new wpf application, copy xaml, add language override, add converter and set:

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>

这篇关于提示文化是错的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆