I created a style for a textbox in order to set up a watermark for a search box. It's working well but now , the TextChanged event I used to filter out a Listview Content is not triggered. Here's the xaml from my page
<TextBox
Style="{StaticResource WatermarkTextBox}"
Name="txtFilter"
DockPanel.Dock="left"
TextChanged="txtFilter_TextChanged" />
And the Style :
<Style x:Key="WatermarkTextBox" TargetType="{x:Type TextBox}">
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<!--<EventSetter Event="TextChanged" Handler="{Binding TextChanged}" />-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Opacity="0.6"
Text="Search...">
<TextBlock.Visibility>
<MultiBinding Converter="{StaticResource WaterMarkBoolToVisibilityConverter}">
<Binding ElementName="inputText" Path="Text.IsEmpty" />
<Binding ElementName="inputText" Path="IsFocused" />
</MultiBinding>
</TextBlock.Visibility>
</TextBlock>
<TextBox x:Name="inputText" Background="Transparent" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
How to keep my txtFilter_TextChanged event from my main page ? It seems I can define a EventSetter in the style but I cannot get the same behavior than for the property, binding it back to the original property value from the control ( Background="{TemplateBinding Background}" for example)