Hi,
I have defined style for my textboxes that would show hints about what to enter when the textbox is empty.
This would be my window:
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type TextBox}" x:Key="stlHintbox">
<Style.Triggers>
<DataTrigger Binding="{Binding Text, RelativeSource={RelativeSource Mode=Self}}" Value="">
<Setter Property="Background">
<Setter.Value>
<VisualBrush Stretch="None">
<VisualBrush.Visual>
<TextBlock Text="First name" FontStyle="Italic" Foreground="LightGray" />
</VisualBrush.Visual>
</VisualBrush>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<TextBox Style="stlHintbox" />
</Grid>
And the error thrown is:
'Set property 'System.Windows.FrameworkElement.Style' threw an exception.' Line number '22' and line position '11'.
with inner exception of:
"'stlHintbox' is not a valid value for property 'Style'."
The style is working OK when placed inside <TextBox.Style>
, so what am I doing wrong here?