Skip to content

Commit 4b5eafc

Browse files
committed
Code improvements.
1 parent 3059579 commit 4b5eafc

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

src/TableView.Properties.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,17 @@ public partial class TableView
170170
public static readonly DependencyProperty CurrentCellSlotProperty = DependencyProperty.Register(nameof(CurrentCellSlot), typeof(TableViewCellSlot?), typeof(TableView), new PropertyMetadata(default, OnCurrentCellSlotChanged));
171171

172172
/// <summary>
173-
/// Identifies the IsHeaderRightClickMenuEnabled dependency property.
173+
/// Identifies the UseRightClickForColumnFilter dependency property.
174174
/// </summary>
175-
public static readonly DependencyProperty IsHeaderRightClickMenuEnabledProperty = DependencyProperty.Register(nameof(IsHeaderRightClickMenuEnabled), typeof(bool), typeof(TableView), new PropertyMetadata(false));
175+
public static readonly DependencyProperty UseRightClickForColumnFilterProperty = DependencyProperty.Register(nameof(UseRightClickForColumnFilter), typeof(bool), typeof(TableView), new PropertyMetadata(false));
176176

177177
/// <summary>
178-
/// Gets or sets a value indicating whether opening the OptionsMenu over header right-click is enabled.
178+
/// Gets or sets a value indicating whether opening the column filter over header right-click is enabled.
179179
/// </summary>
180-
public bool IsHeaderRightClickMenuEnabled
180+
public bool UseRightClickForColumnFilter
181181
{
182-
get => (bool)GetValue(IsHeaderRightClickMenuEnabledProperty);
183-
set => SetValue(IsHeaderRightClickMenuEnabledProperty, value);
182+
get => (bool)GetValue(UseRightClickForColumnFilterProperty);
183+
set => SetValue(UseRightClickForColumnFilterProperty, value);
184184
}
185185

186186
/// <summary>

src/TableViewColumnHeader.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ public TableViewColumnHeader()
5252
DefaultStyleKey = typeof(TableViewColumnHeader);
5353
ManipulationMode = ManipulationModes.TranslateX;
5454
RegisterPropertyChangedCallback(WidthProperty, OnWidthChanged);
55-
56-
// Add IsHeaderRightClickMenuEnabled support
5755
RightTapped += OnRightTapped;
5856
}
5957

@@ -69,28 +67,20 @@ private void OnWidthChanged(DependencyObject sender, DependencyProperty dp)
6967
}
7068

7169
/// <summary>
72-
/// Handles the RightTapped event to show the OptionsMenu.
70+
/// Handles the RightTapped event.
7371
/// </summary>
7472
private void OnRightTapped(object sender, RightTappedRoutedEventArgs e)
7573
{
76-
// Check if right-click is enabled via TableView
77-
if (_tableView?.IsHeaderRightClickMenuEnabled != true)
78-
{
79-
return;
80-
}
81-
82-
// Don't show menu if currently resizing column
83-
if (IsSizingCursor)
74+
// Check if right-click is enabled via TableView or colmun is currently resizing
75+
if (_tableView?.UseRightClickForColumnFilter != true || IsSizingCursor)
8476
{
8577
return;
8678
}
8779

88-
// Simulate button click if options button is available and either filtering or sorting is enabled
80+
// Shows the button's flyout if options button is available and either filtering or sorting is enabled
8981
if (_optionsButton is not null && (CanFilter || CanSort))
9082
{
91-
// Trigger the button's flyout by simulating a click
92-
_optionsButton.Flyout?.ShowAt(_optionsButton);
93-
83+
_optionsButton.Flyout?.ShowAt(_optionsButton);
9484
e.Handled = true;
9585
}
9686
}

0 commit comments

Comments
 (0)