在文本框的工具提示中显示文本框文本与warapping [英] Show textbox text in tooltip of text box with warapping

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

问题描述

我的代码如下。但它在工具提示中没有显示任何内容。请帮助。提前谢谢。



My code is following.But it display nothing in tool tip.Please help.Thanks in advance.

<TextBox Name="decisionBox" Text="Decision" Padding="25,25,25,25" TextWrapping="Wrap" MaxHeight="117" MaxWidth="110" HorizontalAlignment="Center" VerticalAlignment="Center">           
              <TextBox.ToolTip>
                  <ToolTip>
                      <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TextBox}, Path=Text}" Visibility="Visible">
                      </TextBlock>
                  </ToolTip>
              </TextBox.ToolTip>

          </TextBox>

推荐答案

如果您能理解下面的问题,那么您可以试一试。



您可以简单地使用文本框的工具提示属性并绑定文本,除非您不想在文本框上进行任何复杂或自定义验证。

Hi if understand your question below is the solution you can give a try.

You can simply use tooltip property of textbox and bind the text unless you dont want to do any complex or custom validations on your textbox.
<TextBox  ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Name="decisionBox" Text="Decision" Padding="25,25,25,25" TextWrapping="Wrap" MaxHeight="117" MaxWidth="110" HorizontalAlignment="Center" VerticalAlignment="Center">
</TextBox>


OK, if you want to show the tooltip wrapped then try below code. you need to add Tooltip Control to handle this.

You can change the width of text block according to your requirement.I have set as 200.







<textbox text="This is a Demo, Hello World" name="decisionBox" padding="25,25,25,25" textwrapping="Wrap" maxheight="117" maxwidth="110" horizontalalignment="Center" verticalalignment="Center">           
       <textbox.tooltip>
             <tooltip datacontext="{Binding Path=PlacementTarget,RelativeSource={x:Static RelativeSource.Self}}">
                 <textblock text="{Binding Text}" textwrapping="Wrap" width="200" />
             </tooltip>
       </textbox.tooltip>
</textbox>







Hope I have answered your question.Thanks


这篇关于在文本框的工具提示中显示文本框文本与warapping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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