I made some HeaderTemplate for Combobox.GroupStyle in order to display items in groups. And know I need to do some operations with the Combobox when user clicks on the GroupHeader. I have tried to write a trigger in my HedaerTemplate for Combobox.GroupStyle, but it doesn’t work. Below is full code of the combobox:
<ComboBox x:Name="comboBox" DisplayMemberPath="Type"
HorizontalAlignment="Center" VerticalAlignment="Top"
Margin="5" MinWidth="100">
<ComboBox.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}"
FontWeight="Bold"
Margin="0,5,0,0"
Padding="3" Background="LightGreen" MouseDown="TextBlock_MouseDown">
</TextBlock>
<DataTemplate.Triggers>
<EventTrigger RoutedEvent="TextBlock.MouseDown">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.Target="{Binding RelativeSource ={RelativeSource TemplatedParent}}"
From="0" Storyboard.TargetProperty="Width"
To="300" Duration="0:0:5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ComboBox.GroupStyle>
</ComboBox>
I took the property “Width” just for example. But it didn’t work right. Animation expands GroupHeader, not entire ComboBox.
Your TemplateBinding binds to the item where the template is applied to, i.e., the header. Perhaps you need to set the binding as
?
(Sorry, didn’t try the code myself.)