Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RightMouseClick in cell #38

Open
VisualAlf opened this issue Aug 19, 2024 · 1 comment · May be fixed by #85
Open

Add RightMouseClick in cell #38

VisualAlf opened this issue Aug 19, 2024 · 1 comment · May be fixed by #85
Labels
enhancement New feature or request
Milestone

Comments

@VisualAlf
Copy link

I need that in order to display further information on a clicked cell.
Makes it also possible to have a cell-based contextmenu, or something like a hyperlink.

Implementation should be not so complicated:

  1. create new Eventargs:
public class TableViewCellRightTapEventArgs : HandledEventArgs
{
    public TableViewCellRightTapEventArgs(int row, int col, object dataContext)
    {
        Row = row;
        Column = col;
        DataContext = dataContext;
    }

    public int Row { get; }
    public int Column { get; }
    public object DataContext{ get; }
}

with row/column obvious, DataContext showing the whole item from ItemsCollection[row].

  1. in TableView add a new Event + Handler:
    public event EventHandler<TableViewCellRightTapEventArgs>? CellRightTap;
    internal void OnCellRightTap(TableViewCellRightTapEventArgs args)
    {
        CellRightTap?.Invoke(this, args);
    }
  1. in TableViewCell add:
    protected override void OnRightTapped(RightTappedRoutedEventArgs e)
    {
        base.OnRightTapped(e);
        var args = new TableViewCellRightTapEventArgs(Slot.Row, Slot.Column, DataContext);

        TableView.OnCellRightTap(args);
    }

Then in Xaml you can say:

            <table:TableView x:Name="tableView1"
                             CellRightTap="tableView1_CellRightTap" ... />

I also thought about including Content from the cell. But I feel that might publish information about the internal realisation (eg. TextBox/CheckBox/...) which should be probably hidden.

@VisualAlf VisualAlf added the enhancement New feature or request label Aug 19, 2024
@w-ahmad
Copy link
Owner

w-ahmad commented Sep 9, 2024

Thank you, @VisualAlf, for your suggestions. I appreciate that you've highlighted a feature that could enhance the control's customizability.

@w-ahmad w-ahmad added this to the v1.3.0 milestone Sep 9, 2024
@w-ahmad w-ahmad linked a pull request Dec 16, 2024 that will close this issue
@w-ahmad w-ahmad linked a pull request Dec 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants