How to catch expander header click event in WPF? Thanks
<Expander IsExpanded="{Binding Items[0], Mode=OneWay, Converter={StaticResource expanderExpandedConverter}}" HorizontalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Hidden" Loaded="Expander_Loaded" >
<Expander.Header>
<DockPanel PreviewMouseLeftButtonDown="Expander_MouseLeftButtonUp">
<TextBlock Text="{Binding Path=Name}" Style="{StaticResource GroupStyle}" ScrollViewer.HorizontalScrollBarVisibility="Hidden"></TextBlock>
</DockPanel>
</Expander.Header>
<Expander.Style>
<Style TargetType="{x:Type Expander}">
<Setter Property="TextElement.FontFamily" Value="Arial Nova"/>
<Setter Property="BorderThickness" Value="0,0,0,1"/>
<Setter Property="BorderBrush" Value="Black"/>
</Style>
</Expander.Style>
<Expander.Content>
<ItemsPresenter />
</Expander.Content>
</Expander>
I tried with this but it doesn't catch the event if I click on expander's toggle arrow
What you want to do is to define a handler for preview left mouse button up and check for the original source as the toggle button in the expander header whose name is "HeaderSite"
XAML...
code behind...