This project has moved. For the latest updates, please go here.

WatermarkTextBlock should inherit custom TextBlock style

Nov 8, 2012 at 7:07 AM

I use both WatermarkedTextBox:es as well as ordinary TextBox:es. I have created a Custom style for the ordinary TextBox and I would like to apply this style for WatermarkTextBox as well (with the possibility to customize certain properties).

I tried this:

<Style TargetType="extToolkit:WatermarkTextBox" BasedOn="{StaticResource {x:Type          TextBox}}">
     <Setter Property="WatermarkTemplate">
          <Setter.Value>
               <DataTemplate>
                    <TextBlock Text="{Binding}" FontStyle="Italic" Focusable="False"                                             Foreground="DarkGray" />
               </DataTemplate>
          </Setter.Value>
     </Setter>
</Style>

When I use the BasedOn attribute the style is inherited but the Watermark dissapears. If I remove the BasedOn attibute the Watermark displays correctly but obviously the style is reset to default style.

Is there an easy way to accomplish this?