<Style TargetType="{x:Type TextBox}">
<Setter Property="Margin" Value="1"></Setter>
<Setter Property="Background" Value="{x:Null}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="ToolTip">
<Setter.Value>
<DockPanel Background="Gray">
<TextBlock Text="{Binding Source={ TextBox.Text}}"/>
</DockPanel>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Wheat"></Setter>
</Trigger>
</Style.Triggers>
</Style>
========================================
"<TextBlock Text="{Binding Source={ TextBox.Text}}"/>"
I want to bind the textbox text to the Textbox's property such as text or something. but you know what I think above dose't work. can you help me ,thank you very much
Here is the answer
<TextBox Text="Now is the winter of our discontent Made glorious summer by this sun of York; And all the clouds that lour'd upon our house In the deep bosom of the ocean buried."
ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
Width="100" Margin="10"/>
It was found at https://wpf.2000things.com/2011/08/29/374-using-a-tooltip-to-display-the-full-contents-of-a-textbox/
Try this Code:
<Style TargetType="ToolTip">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToolTip">
<DockPanel Background="Gray">
<ContentPresenter/>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Margin" Value="1"/>
<Setter Property="Background" Value="{x:Null}"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="ToolTip" Value="{Binding Text, RelativeSource={RelativeSource self}}"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Wheat"/>
</Trigger>
</Style.Triggers>
</Style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With