Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in XAML - The TypeConverter for "Style" does not support converting from a string

Tags:

styles

wpf

I have a textbox that I want to be watermarked. In my window.resources section I added the style included in its entirety below.

When I set the style on the textbox, Blend 3 Beta displays the following message:

'The TypeConverter for "Style" does not support converting from a string'

What is going on and how do I fix this?

<Style x:Key="WaterMarkTextBoxStyle" BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type TextBox}">
                <Grid>
                    <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    <TextBlock x:Name="textBlock" Opacity="0.345" Text="Enter Text Here" TextWrapping="Wrap" Visibility="Hidden" />
                </Grid>
                <ControlTemplate.Triggers>
                    <MultiTrigger>
                        <MultiTrigger.Conditions>
                            <Condition Property="IsFocused" Value="False" />
                            <Condition Property="Text" Value="" />
                        </MultiTrigger.Conditions>
                        <Setter Property="Visibility" TargetName="textBlock" Value="Visible" />
                    </MultiTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
like image 667
DenaliHardtail Avatar asked Jun 18 '09 15:06

DenaliHardtail


1 Answers

You should be writing,

<TextBox Style="{StaticResource WaterMarkTextBoxStyle}" />

Assuming your Style is in Resources.

like image 168
SLaks Avatar answered Oct 06 '22 22:10

SLaks