我有一个文本框,可以引导用户输入文本进行搜索。
<TextBox Background="White"
Text="{Binding Path=Selected, UpdateSourceTrigger=PropertyChanged}"
TextChanged="textboxsearch_TextChanged"
Grid.Column="4" Margin="0,0,11,10" Height="22" Grid.ColumnSpan="2">
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Text" Value="">
<Setter Property="Foreground" Value="{StaticResource SearchHint}"/>
</Trigger>
</Style.Triggers>
<Setter Property="VerticalAlignment" Value="Bottom"/>
</Style>
</TextBox.Style>
</TextBox>
风格:
<VisualBrush x:Key="SearchHint" TileMode="None" Stretch="None" AlignmentX="Center">
<VisualBrush.Transform>
<TranslateTransform X="5" Y="0" />
</VisualBrush.Transform>
<VisualBrush.Visual>
<Grid>
<TextBlock FontStyle="Italic"
Foreground="Black"
Background="Black"
Text="Enter search text…" />
</Grid>
</VisualBrush.Visual>
</VisualBrush>
为什么我运行程序时 Text="Enter search text..." 不可见?谢谢