0
我試圖創建文本框的提示,這是在我的應用程序中所有的TextBox我的風格代碼:如何在它的風格結合的文本框的工具提示標籤
我已經設置工具提示該文本框(1)
我想要的結合工具提示值的文本框(3)
現在,我只能讓「搜索...」的出現(2)
請幫助
更新代碼
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BTL.Themes">
<Style xmlns:sys="clr-namespace:System;assembly=mscorlib"
x:Key="TextField"
TargetType="{x:Type TextBox}">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontWeight" Value="Regular" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource BodyForeground1}" />
<Setter Property="FontSize" Value="13" />
<Setter Property="CaretBrush" Value="{DynamicResource BodyForeground1}" />
<Setter Property="ToolTipService.InitialShowDelay" Value="250" />
<Setter Property="Height" Value="24" />
<Setter Property="BorderBrush" Value="{DynamicResource TextFieldNormalBorderBrush}" />
<Setter Property="BorderThickness" Value="0 0 0 1" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<ControlTemplate.Resources>
<VisualBrush x:Key="Hint"
AlignmentX="Left"
AlignmentY="Center"
Stretch="None">
<VisualBrush.Visual>
<Label Content="Search..." Foreground="LightGray" />
</VisualBrush.Visual>
</VisualBrush>
</ControlTemplate.Resources>
<Border Height="{TemplateBinding Height}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost"
Height="{TemplateBinding Height}"
Margin="0 0 0 0"
VerticalAlignment="Bottom"
Focusable="false"
Foreground="{TemplateBinding Foreground}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="{DynamicResource DisabledOpacity}" />
<Setter Property="BorderThickness" Value="0 0 0 0.5" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
<!--<Setter Property="BorderThickness" Value="0 0 0 2" />-->
<Setter Property="BorderBrush" Value="{DynamicResource BodyFocusVisual}" />
</Trigger>
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">
<Setter Property="Background" Value="{StaticResource Hint}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
顯示您的源代碼,但不能作爲圖像... – ddb
只需更新代碼,請大家看看 我想是這樣的: <標籤內容=「綁定工具提示」前景=「淺灰色」 /> (當然,它不工作) –