Error in XAML - TypeConverter for "Style" does not support conversion from string

I have a text box in which I want to be a watermark. In the window.resources section, I added the style included in its full description below.

When I set the style in the text box, Blend 3 Beta displays the following message:

'TypeConverter for "Style" does not support conversion from string "

What is happening and how to fix it?

<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>
+3
source share
1 answer

You have to write

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

Assuming yours Styleis in Resources.

+4
source

Source: https://habr.com/ru/post/1710776/


All Articles