anpin/ContextMenuContainer

How do we use this?

Closed this issue · 21 comments

The code here doesn't load in VS (src folder, just looking for iOS and Droid). So how do you use this in an application?

Screen Shot 2021-06-06 at 8 52 00 PM

anpin commented

I just downloaded the code from here and tried to open the solution and it fails with the error that's on the screenshot. I didn't realize it was on nuget and it seems to, almost, work. I'm trying to use it in a CarouselView, it doesn't quite function. I attached a small sample if you wanna check it out,
TestSfListView.zip
please.

anpin commented

@rezamohamed sorry haven't seen the screenshot in the email client. I guess you need the MSBuild.Sdk.Extras installed on mac somehow as the error suggests, but I'm building it on Windows so not sure if it is viable. I'll check you repro later this week.

The issue is that on the CarouselView, the first CarouselItem is displayed in the background. In the image below, you can see the first item displayed between the two side-by-side (behind, like it's in the background). There is also a jitter on first appearing.

Screen Shot 2021-06-07 at 12 52 35 PM

anpin commented

yep! that was it! thanks, looks to be working like a charm now.

Pavel, from the context actions, can I execute a codebehind clicked event rather than a viewmodel command and also pass the command parameter to the codebehind event?

anpin commented

ContextMenuItem has InvokeCommand method which executes the Command like this
image

I'm on v1.0.5, I don't see Invoked. Screenshot below.
Screen Shot 2021-06-08 at 10 28 52 AM

anpin commented

right, because it is a method, not a property

I'm not following. My question is I have the Contextmenu in Carousel.xaml, and I have an event in Carousel.xaml.cs that I want to trigger when the user clicks ContextMenu. The Command triggers a command in the ViewModel, How would I invoke an event in the codebehind?

With the InvokeCommand you mentioned above, I guess I am unclear how to use it.

anpin commented

Any chance of adding it please? just a way to trigger an event, and send the parameters to the event via CommandParameter. It would make the component fully usable at that point.

anpin commented

Appreciate that, will keep an eye out for a new version. This component fills a big gap, in my opinion, especially for Carousel where the swipe methods for actions are limited. Great work.

anpin commented

Appreciate that, will keep an eye out for a new version. This component fills a big gap, in my opinion, especially for Carousel where the swipe methods for actions are limited. Great work.

Please find version 1.0.6 on nuget with the event added

ItemTapped event works, but the EventArgs is not working. My expectation was that the EventArgs would populate whatever is defined in the CommandParameter...but this isn't working. The CommandParameter does work for the Command however.
Screen Shot 2021-06-10 at 1 38 44 PM

anpin commented

I do see it now, in the BindingContext of the ContextMenuItem that is returned via sender. Is that what you are referring to? I would have to drill down to get that info, usually it would just be sent via EventArgs, so it was different. Can you confirm, please?

    private void CarouselDelete_OnItemTapped(object sender, EventArgs e)
    {
        var x = (ContextMenuItem) sender;
        var y = x.BindingContext;
    }

Screen Shot 2021-06-11 at 12 31 01 AM

x, y:

Screen Shot 2021-06-11 at 12 31 35 AM

anpin commented

yep! I see it now. Works perfectly. Thanks