Connect GridViewColumnHeader.Click event from ListView
I have a ListView and I want to connect the event GridViewColumnHeader.Click to the function PersonListView_Click
How can I setup the ConnectEvent in order to recieve the click event when I click on the header/GridViewColumn of my ListView ?
Code: Select all
<ListView ItemsSource="{Binding Person}" GridViewColumnHeader.Click="PersonListView_Click">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Name}" />
Code: Select all
protected override bool ConnectEvent(object source, string eventName, string handlerName)
{
if (eventName == "Click" && handlerName == "PersonListView_Click")
{
Debug.Log(source);
ViewBase v = ((ListView)source).View;
// += this.PersonListView_Click;
return true;
}
return false;
}
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Connect GridViewColumnHeader.Click event from ListView
In this case you should use the AddHandler method because ListView does not define the Click event and you are using it as an attached routed event:
Code: Select all
protected override bool ConnectEvent(object source, string eventName, string handlerName)
{
if (eventName == "Click" && handlerName == "PersonListView_Click")
{
((ListView)source).AddHandler(GridViewColumnHeader.ClickEvent, new RoutedEventHandler(this.PersonListView_Click));
return true;
}
return false;
}Re: Connect GridViewColumnHeader.Click event from ListView
Thank you for your help!
Who is online
Users browsing this forum: Bing [Bot] and 4 guests