Skip to content

Commit d19ec5e

Browse files
committed
Implemented by Triggering the button's flyout by simulating a click.
Fixes #63
1 parent ef6e49b commit d19ec5e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/TableViewColumnHeader.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public TableViewColumnHeader()
5252
DefaultStyleKey = typeof(TableViewColumnHeader);
5353
ManipulationMode = ManipulationModes.TranslateX;
5454
RegisterPropertyChangedCallback(WidthProperty, OnWidthChanged);
55+
56+
// Add right-click support
57+
RightTapped += OnRightTapped;
5558
}
5659

5760
/// <summary>
@@ -65,6 +68,27 @@ private void OnWidthChanged(DependencyObject sender, DependencyProperty dp)
6568
}
6669
}
6770

71+
/// <summary>
72+
/// Handles the RightTapped event to show the options flyout.
73+
/// </summary>
74+
private void OnRightTapped(object sender, RightTappedRoutedEventArgs e)
75+
{
76+
// Don't show menu if currently resizing column
77+
if (IsSizingCursor)
78+
{
79+
return;
80+
}
81+
82+
// Simulate button click if options button is available and either filtering or sorting is enabled
83+
if (_optionsButton is not null && (CanFilter || CanSort))
84+
{
85+
// Trigger the button's flyout by simulating a click
86+
_optionsButton.Flyout?.ShowAt(_optionsButton);
87+
88+
e.Handled = true;
89+
}
90+
}
91+
6892
/// <summary>
6993
/// Sorts the column in the specified direction.
7094
/// </summary>

0 commit comments

Comments
 (0)