When I have a grid that groups items is there a way to expand/collapse the group when the user clicks on the text in the header? Right now the only way to expand/collapse a group is to click on the expand button in the header.
To accomplish your task handle the MouseLeftButtonUp event in the following manner:
[C#]Open in popup window
private void tableView1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
TableView view = sender as TableView;
TableViewHitInfo hi = view.CalcHitInfo(e.OriginalSource as DependencyObject);
if (hi.HitTest == TableViewHitTest.GroupValue)
ToggleExpandedState(view);
}
private void ToggleExpandedState(TableView view)
{
if (view.Grid.IsGroupRowExpanded(view.FocusedRowHandle))
view.CollapseFocusedRow();
else
view.ExpandFocusedRow();
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น