Click here to Skip to main content
15,437,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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">           
                      <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TextBox}, Path=Text}" Visibility="Visible">

Updated 11-Oct-21 0:15am

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">
Share this answer
Nitin Go 24-Jun-14 7:37am    
Rohit - it not wrap the tooltip.
Rohit R Chavan 25-Jun-14 1:35am    
Hi Nitin I didn't get what exactly you want. Tooltip should Wrap or NoWrap
Nitin Go 25-Jun-14 3:23am    
Tooltip should wrap.
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">           
             <tooltip datacontext="{Binding Path=PlacementTarget,RelativeSource={x:Static RelativeSource.Self}}">
                 <textblock text="{Binding Text}" textwrapping="Wrap" width="200" />

Hope I have answered your question.Thanks
Share this answer
this is best solution.

<Setter Property = "HorizontalOffset" Value="50"/>

<Setter Property = "VerticalOffset" Value="50"/>

<Setter Property = "Background" Value="#6BC16C"/>

<Setter Property = "Foreground" Value="{DynamicResource MainBlueColor}"/>

<Setter Property = "FontSize" Value="14"/>

<Setter Property = "FontWeight" Value="Bold"/>

<Setter Property = "FontFamily" Value="Roboto"/>

<TextBox x:Name="tbKeymsgGoal"  TextAlignment="Center"  Margin="0,60,0,0" Style="{StaticResource SpeechProWaterMarkStyle}"  Tag="e.g.Resources" FontFamily="Roboto" FontSize="14" FontWeight="Normal"  TextWrapping="Wrap" HorizontalAlignment="Center" Width="200" Height="30"  Background="{DynamicResource SlideContent.White}"  Template="{DynamicResource TextBoxBaseControlTemplate}" VerticalAlignment="Top" Padding="5" Foreground="{DynamicResource MainBlueColor}" >
                                            <ToolTip DataContext="{Binding Path=PlacementTarget,RelativeSource={x:Static RelativeSource.Self}}" Style="{StaticResource MyTooltip}">
                                                <TextBlock Text="{Binding Text}"  TextWrapping="Wrap" Width="200"></TextBlock>
Share this answer
CHill60 11-Oct-21 7:09am    
Hard to tell with such poor formatting. An explanation of why your solution is better than the others here would be useful

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900