Skip to content

Commit 3059579

Browse files
committed
Added property IsHeaderRightClickMenuEnabled to enable showing OptionsMenu, default is false.
1 parent d19ec5e commit 3059579

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
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 IsHeaderRightClickMenuEnabled dependency property.
174+
/// </summary>
175+
public static readonly DependencyProperty IsHeaderRightClickMenuEnabledProperty = DependencyProperty.Register(nameof(IsHeaderRightClickMenuEnabled), typeof(bool), typeof(TableView), new PropertyMetadata(false));
176+
177+
/// <summary>
178+
/// Gets or sets a value indicating whether opening the OptionsMenu over header right-click is enabled.
179+
/// </summary>
180+
public bool IsHeaderRightClickMenuEnabled
181+
{
182+
get => (bool)GetValue(IsHeaderRightClickMenuEnabledProperty);
183+
set => SetValue(IsHeaderRightClickMenuEnabledProperty, value);
184+
}
185+
172186
/// <summary>
173187
/// Gets the collection view associated with the TableView.
174188
/// </summary>

src/TableViewColumnHeader.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public TableViewColumnHeader()
5353
ManipulationMode = ManipulationModes.TranslateX;
5454
RegisterPropertyChangedCallback(WidthProperty, OnWidthChanged);
5555

56-
// Add right-click support
56+
// Add IsHeaderRightClickMenuEnabled support
5757
RightTapped += OnRightTapped;
5858
}
5959

@@ -69,10 +69,16 @@ private void OnWidthChanged(DependencyObject sender, DependencyProperty dp)
6969
}
7070

7171
/// <summary>
72-
/// Handles the RightTapped event to show the options flyout.
72+
/// Handles the RightTapped event to show the OptionsMenu.
7373
/// </summary>
7474
private void OnRightTapped(object sender, RightTappedRoutedEventArgs e)
7575
{
76+
// Check if right-click is enabled via TableView
77+
if (_tableView?.IsHeaderRightClickMenuEnabled != true)
78+
{
79+
return;
80+
}
81+
7682
// Don't show menu if currently resizing column
7783
if (IsSizingCursor)
7884
{

0 commit comments

Comments
 (0)