Skip to content

Commit

Permalink
Merge pull request #108 from VisualAlf/ContextReqForWindow
Browse files Browse the repository at this point in the history
Fire ContextFlyoutOpened even if Flyout is null
  • Loading branch information
w-ahmad authored Feb 17, 2025
2 parents 20c3fe2 + bc74085 commit eb78bd4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/EventArgs/TableViewCellContextFlyoutEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class TableViewCellContextFlyoutEventArgs : HandledEventArgs
/// <param name="cell">The cell for which the context flyout is being shown.</param>
/// <param name="item">The item associated with the cell.</param>
/// <param name="flyout">The context flyout to be shown.</param>
public TableViewCellContextFlyoutEventArgs(TableViewCellSlot slot, TableViewCell cell, object item, FlyoutBase flyout)
public TableViewCellContextFlyoutEventArgs(TableViewCellSlot slot, TableViewCell cell, object item, FlyoutBase? flyout)
{
Slot = slot;
Cell = cell;
Expand All @@ -41,5 +41,5 @@ public TableViewCellContextFlyoutEventArgs(TableViewCellSlot slot, TableViewCell
/// <summary>
/// Gets the context flyout to be shown.
/// </summary>
public FlyoutBase Flyout { get; }
public FlyoutBase? Flyout { get; }
}
4 changes: 2 additions & 2 deletions src/EventArgs/TableViewRowContextFlyoutEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class TableViewRowContextFlyoutEventArgs : HandledEventArgs
/// <param name="row">The TableViewRow associated with the event.</param>
/// <param name="item">The item associated with the row.</param>
/// <param name="flyout">The flyout to be shown.</param>
public TableViewRowContextFlyoutEventArgs(int index, TableViewRow row, object item, FlyoutBase flyout)
public TableViewRowContextFlyoutEventArgs(int index, TableViewRow row, object item, FlyoutBase? flyout)
{
Index = index;
Row = row;
Expand All @@ -41,5 +41,5 @@ public TableViewRowContextFlyoutEventArgs(int index, TableViewRow row, object it
/// <summary>
/// Gets the flyout to be shown.
/// </summary>
public FlyoutBase Flyout { get; }
public FlyoutBase? Flyout { get; }
}
8 changes: 2 additions & 6 deletions src/TableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,12 +1303,10 @@ private void EnsureCellsStyle()
/// </summary>
internal void ShowRowContext(TableViewRow row, Point position)
{
if (RowContextFlyout is null) return;

var eventArgs = new TableViewRowContextFlyoutEventArgs(row.Index, row, row.Content, RowContextFlyout);
RowContextFlyoutOpening?.Invoke(this, eventArgs);

if (!eventArgs.Handled)
if (RowContextFlyout is not null && !eventArgs.Handled)
{
var presenter = row.FindDescendant<ListViewItemPresenter>();

Expand All @@ -1326,12 +1324,10 @@ internal void ShowRowContext(TableViewRow row, Point position)
/// </summary>
internal void ShowCellContext(TableViewCell cell, Point position)
{
if (CellContextFlyout is null) return;

var eventArgs = new TableViewCellContextFlyoutEventArgs(cell.Slot, cell, cell.Row?.Content!, CellContextFlyout);
CellContextFlyoutOpening?.Invoke(this, eventArgs);

if (!eventArgs.Handled)
if (CellContextFlyout is not null && !eventArgs.Handled)
{
CellContextFlyout.ShowAt(cell, new FlyoutShowOptions
{
Expand Down

0 comments on commit eb78bd4

Please sign in to comment.