I have a listview containing a header which is supposed to respond when clicked.
Is there a way to create a clickable ListView header?
There is no problem in putting for example Button as a header in your ListView :
<ListView Width="100" Margin="20">
<ListView.Header>
<Button Content="Clickable header" Click="Button_Click"/>
</ListView.Header>
<x:String>Sample element</x:String>
<x:String>Sample element</x:String>
<x:String>Sample element</x:String>
</ListView>
Of course you can change style of the button to fulfill your needs. Also instead changing the header you can also change HeaderTemplate :
<ListView Width="100" Margin="20" Header="Clickable header">
<ListView.HeaderTemplate>
<DataTemplate>
<Button Content="{Binding}" Click="Button_Click"/>
</DataTemplate>
</ListView.HeaderTemplate>
<x:String>Sample element</x:String>
<x:String>Sample element</x:String>
<x:String>Sample element</x:String>
</ListView>
I solved the issue by adding a behavior for ListView.HeaderTemplate:
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Tapped" SourceObject="{Binding ElementName=ListViewHeader}">
<Core:InvokeCommandAction Command="{Binding DataContext.OnShowAllTicketsPressedCommand, ElementName=Project}"/>
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.