Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/EventArgs/TableViewCellDoubleTappedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.ComponentModel;

namespace WinUI.TableView;

/// <summary>
/// Provides data for the CellDoubleTapped event.
/// </summary>
public partial class TableViewCellDoubleTappedEventArgs : HandledEventArgs
{
/// <summary>
/// Initializes a new instance of the TableViewCellDoubleTappedEventArgs class.
/// </summary>
/// <param name="slot">The slot of the cell.</param>
/// <param name="cell">The TableViewCell associated with the event.</param>
/// <param name="item">The item associated with the cell.</param>
public TableViewCellDoubleTappedEventArgs(TableViewCellSlot slot, TableViewCell cell, object? item)
{
Slot = slot;
Cell = cell;
Item = item;
}

/// <summary>
/// Gets the slot of the cell.
/// </summary>
public TableViewCellSlot Slot { get; }

/// <summary>
/// Gets the TableViewCell associated with the event.
/// </summary>
public TableViewCell Cell { get; }

/// <summary>
/// Gets the item associated with the cell.
/// </summary>
public object? Item { get; }
}
37 changes: 37 additions & 0 deletions src/EventArgs/TableViewRowDoubleTappedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.ComponentModel;

namespace WinUI.TableView;

/// <summary>
/// Provides data for the RowDoubleTapped event.
/// </summary>
public partial class TableViewRowDoubleTappedEventArgs : HandledEventArgs
{
/// <summary>
/// Initializes a new instance of the TableViewRowDoubleTappedEventArgs class.
/// </summary>
/// <param name="index">The index of the row.</param>
/// <param name="row">The TableViewRow associated with the event.</param>
/// <param name="item">The row associated with double tap/click.</param>
public TableViewRowDoubleTappedEventArgs(int index, TableViewRow row, object? item)
{
Index = index;
Row = row;
Item = item;
}

/// <summary>
/// Gets the index of the row.
/// </summary>
public int Index { get; }

/// <summary>
/// Gets the TableViewRow associated with the event.
/// </summary>
public TableViewRow Row { get; }

/// <summary>
/// Gets the item associated with the row.
/// </summary>
public object? Item { get; }
}
28 changes: 28 additions & 0 deletions src/TableView.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,34 @@ protected virtual void OnRowContextFlyoutOpening(TableViewRowContextFlyoutEventA
RowContextFlyoutOpening?.Invoke(this, args);
}

/// <summary>
/// Event triggered when a row is double-tapped.
/// </summary>
public event EventHandler<TableViewRowDoubleTappedEventArgs>? RowDoubleTapped;

/// <summary>
/// Called before the <see cref="RowDoubleTapped"/> event occurs.
/// </summary>
/// <param name="args">The event data.</param>
protected internal virtual void OnRowDoubleTapped(TableViewRowDoubleTappedEventArgs args)
{
RowDoubleTapped?.Invoke(this, args);
}

/// <summary>
/// Event triggered when a cell is double-tapped.
/// </summary>
public event EventHandler<TableViewCellDoubleTappedEventArgs>? CellDoubleTapped;

/// <summary>
/// Called before the <see cref="CellDoubleTapped"/> event occurs.
/// </summary>
/// <param name="args">The event data.</param>
protected internal virtual void OnCellDoubleTapped(TableViewCellDoubleTappedEventArgs args)
{
CellDoubleTapped?.Invoke(this, args);
}

/// <summary>
/// Event triggered when the cell context flyout is opening.
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions src/TableViewCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,22 @@ private double GetHorizontalGridlineHeight()
/// <inheritdoc/>
protected override async void OnDoubleTapped(DoubleTappedRoutedEventArgs e)
{
var eventArgs = new TableViewCellDoubleTappedEventArgs(Slot, this, Row?.Content);
TableView?.OnCellDoubleTapped(eventArgs);
e.Handled = eventArgs.Handled;

if (e.Handled) return;

base.OnDoubleTapped(e);

if (!IsReadOnly && TableView is not null && !TableView.IsEditing && !Column?.UseSingleElement is true)
{
e.Handled = await BeginCellEditing(e);
}
else
{
e.Handled = true;
}
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions src/TableViewRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ protected override void OnTapped(TappedRoutedEventArgs e)
}
}

/// <inheritdoc/>
protected override void OnDoubleTapped(DoubleTappedRoutedEventArgs e)
{
var eventArgs = new TableViewRowDoubleTappedEventArgs(Index, this, Content);
TableView?.OnRowDoubleTapped(eventArgs);
e.Handled = eventArgs.Handled;

base.OnDoubleTapped(e);
}

/// <inheritdoc/>
protected override Size ArrangeOverride(Size finalSize)
{
Expand Down
Loading