WPF 中带有方括号或圆括号的工具提示的奇怪呈现行为
我有一个按钮,其工具提示定义如下:
<Button Width="25" ToolTip="Delete selected name (Ctrl + F12).">-</Button>
当我在运行时将鼠标悬停在按钮上时,工具提示显示为
(.删除选定的名称 (Ctrl + F12
我也尝试过定义工具提示,因为
<Button Width="25">
<Button.ToolTip>Delete selected name (Ctrl + F12).</Button.ToolTip>
-
</Button>
我也尝试过使用括号而不是圆括号。
在所有情况下,最终结束后的文本)或 ] 被切断并附加到字符串的前面,以开头 ( 或 [ 为前缀。我已经在 google 上搜索了工具提示所需的任何特殊转义提示,但结果却很干燥。我是在某个地方错过了明显的内容,还是我最终会失去控制?:-|
这是使用.Net框架4.0版本。
I have a button with a tool tip defined as follows:
<Button Width="25" ToolTip="Delete selected name (Ctrl + F12).">-</Button>
When I hover over the button at run time the tooltip displays as
(.Delete selected name (Ctrl + F12
I have also tried defining the tooltip as
<Button Width="25">
<Button.ToolTip>Delete selected name (Ctrl + F12).</Button.ToolTip>
-
</Button>
I have also tried using brackets instead of parentheses.
In all cases text after the final closing ) or ] is being cut off and perpended to the front of the string, prefixed by an opening ( or [. I have googled for any hint of special escaping needed for tool tips and come up dry. I am I missing the obvious somewhere or am I going finally loosing my grip? :-|
This is using the 4.0 version of the .Net framework.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这有点晚了,但我刚刚遇到这个问题,找不到解决方案。我的不涉及句号,添加空格也没有帮助。
我有一个按钮,其内容绑定到我的视图模型上的一个字符串,类似于“count (0)”,并呈现为“( count (0”)。经过一些修改和使用按钮的模板后,我发现我的按钮包含在 StackPanel 中,其 FlowDirection 设置为 RightToLeft 似乎 Button 控件从父级继承了此值,因此一旦我将 Button 的 FlowDirection 设置回 LeftToRight,问题就解决了
。关于它改变渲染时文本顺序的根本原因,但至少这个解决方案似乎解决了问题。
This is a little late, but I just had this problem and could not find a solution. Mine did not involve a period and adding a space did not help.
I had a Button with its content bound to a string on my view model that was something like "count (0)" and was rendering as "( count (0". After some tinkering around and playing with the button's template, I discovered that my button was contained in a StackPanel with its FlowDirection set RightToLeft. It would seem that the Button control inherits this value from the parent, so as soon as I set the Button's FlowDirection back to LeftToRight, the problem was solved.
I don't know the underlying reason as to why it changes the text's order on render, but at least this solution seems to fix the problem.
我刚刚遇到了同样的问题,我做了一些解决方法,只是在点后面加一个空格,它就像一个魅力。
I've just encountered the same problem, I've done a bit of a workaround which simply was to put a space after a dot and it works like a charm.
迟到了,但我有解决办法。
当 TextBlock/Label 以 RoghtToLeft 流用 StackPanel 包装时,会出现问题。
例如:
解决方法是使用附加属性:
Late, but I have got workaround.
Problem appears when TextBlock/Label is wrapped with StackPanel with flow RoghtToLeft.
For example:
Workaround is to use attached property: