In my Window.Resources I have the following style:
<Style TargetType="TextBox" x:Key="HintText" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style.Resources>
<VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None">
<VisualBrush.Visual>
<Label Content="{DynamicResource EmptyText}" Foreground="LightGray" />
</VisualBrush.Visual>
</VisualBrush>
</Style.Resources>
<Style.Triggers>
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
</Trigger>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
If I use this for 1 TextBox with this,
<Label Content="Test" Foreground="LightGray" />
Test will show up in my TextBox if it's empty. When I try to use this style in different TextBoxes with this,
<Label Content="{DynamicResource EmptyText}" Foreground="LightGray" />
and
<TextBox.Resources>
<sys:String x:Key="EmptyText">Test</sys:String>
</TextBox.Resources>
it doesn't show anything. Is it possible to use this 1 style with a different string that is shown in the TextBox or do I have to make a different style for each TextBox?