用到了telerik:
<telerik:RadWatermarkTextBox BorderThickness="0" Name="txtSearch" Background="{x:Null}" ClipToBounds="True" TextWrapping="Wrap" BorderBrush="#FFCCCCCC" >
<telerik:RadWatermarkTextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding SearchCommand}" CommandParameter="{Binding ElementName=txtSearch}"></KeyBinding>
</telerik:RadWatermarkTextBox.InputBindings>
<telerik:RadWatermarkTextBox.WatermarkContent>
<StackPanel>
<TextBlock Text="测试" />
</StackPanel>
</telerik:RadWatermarkTextBox.WatermarkContent>
</telerik:RadWatermarkTextBox>
注意<i:Interaction>需要使用Blend的System.Windows.Interactivity.dll文件。
<Button Content="确
定" IsDefault="True" Grid.Row="2" Grid.Column="3" Grid.RowSpan="2" Style="{StaticResource Win8StyleBtn}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding SearchCommand}" CommandParameter="{Binding ElementName=txtSearch}"> </i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
DelegateCommand需要Prism中的Microsoft.Practices.Prism.dll
public void ExecuteSearch(Telerik.Windows.Controls.RadWatermarkTextBox radWatermarkTextBox)
{
MessageBox.Show(radWatermarkTextBox.Text);
}