本文介绍了在文本框的工具提示中显示文本框文本与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>

推荐答案

<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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 03:09