效果:
 
 WPF中貌似不能像winfrom里一样直接加提示语,需要使用TextBox.Style,将Trigger标签插入进去。
 贴源码:
<WrapPanel Name="TakeOverExpressNo1">
    <Label Content="物流单号:"></Label>
    <TextBox Grid.Row="9" Grid.Column="1" x:Name="txtTakeOverExpressNo1" Width="250" KeyDown="txtTakeOverExpressNo1_KeyDown">
        <TextBox.Resources>
            <VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="0.5" Stretch="None" AlignmentX="Left">
                <VisualBrush.Visual>
                    <TextBlock FontStyle="Italic" Text="输入后请按回车"/>
                </VisualBrush.Visual>
            </VisualBrush>
        </TextBox.Resources>
        <TextBox.Style>
            <Style TargetType="TextBox">
                <Style.Triggers>
                    <Trigger Property="Text" Value="{x:Null}">
                        <Setter Property="Background" Value="{StaticResource HelpBrush}"/>
                    </Trigger>
                    <Trigger Property="Text" Value="">
                        <Setter Property="Background" Value="{StaticResource HelpBrush}"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </TextBox.Style>
    </TextBox>
</WrapPanel>



















