해당 스타일은 별도의 ResourceDictionary 파일로 분리하여 사용했으나 기존에 사용하고 있던 Resource 파일이 있다면 거기에 추가하거나, 혹은 현재 파일 내부에 삽입해도 된다.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:mwt ="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add TargetType="{x:Type TextBox}" to make this style the default for all TextBoxes. -->
<Style x:Key="WatermarkedTextBox" >
<Setter Property="Control.Template" >
<Setter.Value>
<ControlTemplate TargetType="TextBox" >
<!-- Template derived from Default TextBoxBase. -->
<!-- Added the Label InternalWatermarkLabel together with the surrounding Grid. -->
<Grid>
<mwt:ListBoxChrome Name="Bd"
Background="{TemplateBinding Panel.Background}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
BorderThickness="{TemplateBinding Border.BorderThickness}"
RenderMouseOver="{TemplateBinding UIElement.IsMouseOver}"
RenderFocused="{TemplateBinding UIElement.IsKeyboardFocusWithin}"
SnapsToDevicePixels="True">
<ScrollViewer Name="PART_ContentHost"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
/>
</mwt:ListBoxChrome>
<Label x:Name="InternalWatermarkLabel"
Content="{TemplateBinding Tag}"
Visibility="Collapsed" Focusable="False"
Foreground="Gray"
Background="Transparent"
/>
</Grid>
<ControlTemplate.Triggers>
<!-- The multitrigger is responsible for showing and hiding the watermark. -->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsFocused" Value="False" />
<Condition Property="Text" Value="" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter Property="Visibility" TargetName="InternalWatermarkLabel"
Value="Visible" />
</MultiTrigger.Setters>
</MultiTrigger>
<!-- This trigger mimics the default behavior. -->
<Trigger Property="UIElement.IsEnabled" Value="False" >
<Setter Property="Panel.Background" TargetName="Bd"
Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
<Setter Property="TextElement.Foreground"
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
여기까지 제대로 적용했다면 다음과 같이 동작하는 것을 확인할 수 있다.