Skip to content

Commit a9b4e04

Browse files
authored
Merge pull request #193 from SISTF/fix-issue-62
Implemented by Triggering the button's flyout by simulating a click.
2 parents 4a0e837 + 3c7d9b3 commit a9b4e04

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/TableView.Properties.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ public partial class TableView
169169
/// </summary>
170170
public static readonly DependencyProperty CurrentCellSlotProperty = DependencyProperty.Register(nameof(CurrentCellSlot), typeof(TableViewCellSlot?), typeof(TableView), new PropertyMetadata(default, OnCurrentCellSlotChanged));
171171

172+
/// <summary>
173+
/// Identifies the UseRightClickForColumnFilter dependency property.
174+
/// </summary>
175+
public static readonly DependencyProperty UseRightClickForColumnFilterProperty = DependencyProperty.Register(nameof(UseRightClickForColumnFilter), typeof(bool), typeof(TableView), new PropertyMetadata(false));
176+
177+
/// <summary>
178+
/// Gets or sets a value indicating whether opening the column filter over header right-click is enabled.
179+
/// </summary>
180+
public bool UseRightClickForColumnFilter
181+
{
182+
get => (bool)GetValue(UseRightClickForColumnFilterProperty);
183+
set => SetValue(UseRightClickForColumnFilterProperty, value);
184+
}
185+
172186
/// <summary>
173187
/// Gets the collection view associated with the TableView.
174188
/// </summary>

src/TableViewColumnHeader.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public TableViewColumnHeader()
5252
DefaultStyleKey = typeof(TableViewColumnHeader);
5353
ManipulationMode = ManipulationModes.TranslateX;
5454
RegisterPropertyChangedCallback(WidthProperty, OnWidthChanged);
55+
RightTapped += OnRightTapped;
5556
}
5657

5758
/// <summary>
@@ -65,6 +66,25 @@ private void OnWidthChanged(DependencyObject sender, DependencyProperty dp)
6566
}
6667
}
6768

69+
/// <summary>
70+
/// Handles the RightTapped event.
71+
/// </summary>
72+
private void OnRightTapped(object sender, RightTappedRoutedEventArgs e)
73+
{
74+
// Check if right-click is enabled via TableView or column is currently resizing
75+
if (_tableView?.UseRightClickForColumnFilter != true || IsSizingCursor)
76+
{
77+
return;
78+
}
79+
80+
// Shows the button's flyout if options button is available and filtering is enabled
81+
if (_optionsButton is not null && CanFilter)
82+
{
83+
_optionsButton.Flyout?.ShowAt(_optionsButton);
84+
e.Handled = true;
85+
}
86+
}
87+
6888
/// <summary>
6989
/// Sorts the column in the specified direction.
7090
/// </summary>

0 commit comments

Comments
 (0)