如何禁用“工具提示”在文本框? [英] How to disable "tooltip" on textbox ?
本文介绍了如何禁用“工具提示”在文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在鼠标悬停时禁用文本框的工具提示,请帮助
这是我的文本框控件模板
我是什么尝试过:
< ControlTemplate x:Key =TextboxWithWatermarkTargetType ={x:Type TextBox}> ;
< Border x:Name =borderBorderBrush ={TemplateBinding BorderBrush}BorderThickness ={TemplateBinding BorderThickness}SnapsToDevicePixels =TrueBackground ={TemplateBinding Background}>
< Grid>
< ScrollViewer x:Name =PART_ContentHostFocusable =FalseHorizontalScrollBarVisibility =隐藏VerticalScrollBarVisibility =隐藏/>
< TextBlock Cursor =IBeamVerticalAlignment =Topx:Name =HintPresenterFontFamily ={TemplateBinding FontFamily}FontSize ={TemplateBinding FontSize}FontWeight ={TemplateBinding FontWeight}Margin = 5,0,5,0HorizontalAlignment =LeftForeground ={TemplateBinding Foreground}FontStyle =ItalicOpacity =0Text ={TemplateBinding ToolTip}/>
< / Grid>
< / Border>
< ControlTemplate.Triggers>
< Trigger Property =IsEnabledValue =False>
< Setter Property =OpacityTargetName =borderValue =0.56/>
< / Trigger>
< Trigger Property =TextValue =>
< Setter Property =OpacityTargetName =HintPresenterValue =0.5/>
< / Trigger>
< /ControlTemplate.Triggers>
< / ControlTemplate>
解决方案
共享代码中没有设置工具提示。如果你看到一个,那么它被设置在其他地方 - 在问题中不共享的代码。检查页面或视图或代码隐藏中的实际代码。
更新
为什么不只是使用ToolTipService
和IsEnabled
属性。示例:
< TextBox Text = 启用测试宽度= 100
ToolTipService.IsEnabled = {Binding ElementName = EnabledState,Path = IsChecked}
ToolTipService.ToolTip = 这是文本框的工具提示 />
< CheckBox x:Name = EnabledState Content = 显示工具提示 IsChecked = True Margin = 10 0 />
I want to disable textbox's ToolTip on Mouse Over, Please help
Here is my Textbox Control Template
What I have tried:
<ControlTemplate x:Key="TextboxWithWatermark" TargetType="{x:Type TextBox}"> <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="True" Background="{TemplateBinding Background}"> <Grid> <ScrollViewer x:Name="PART_ContentHost" Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/> <TextBlock Cursor="IBeam" VerticalAlignment="Top" x:Name="HintPresenter" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" Margin="5,0,5,0" HorizontalAlignment="Left" Foreground="{TemplateBinding Foreground}" FontStyle="Italic" Opacity="0" Text="{TemplateBinding ToolTip}"/> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Opacity" TargetName="border" Value="0.56"/> </Trigger> <Trigger Property="Text" Value="" > <Setter Property="Opacity" TargetName="HintPresenter" Value="0.5"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate>
解决方案
There is no tooltip set in the code shared. If you are seeing one, then it is set somewhere else - code that is not shared in the question. Check against the actual code in the Page or View or in the code-behind.
Update
Why not simply work with theToolTipService
and theIsEnabled
property. Example:
<TextBox Text="Is Enable Test" Width="100" ToolTipService.IsEnabled ="{Binding ElementName=EnabledState, Path=IsChecked}" ToolTipService.ToolTip="This is a tooltip for the textbox"/> <CheckBox x:Name="EnabledState" Content="Show Tooltip" IsChecked="True" Margin="10 0" />
这篇关于如何禁用“工具提示”在文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文