Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

ListView ContentAction example does not show a DisplayAlert

$
0
0

Hi,

If you download the example https://developer.xamarin.com/samples/xamarin-forms/UserInterface/ListView/interactivity/ and take a look at it, you see in the interactivityListViewCode.cs file there are ContentActions set. However, in the example of the OnMore event there is page.DisplayAlert tagged.
If I untag this, it gives an error. What I would like to do is a DisplayAlert at that point, or even better call a reload of resources or whole page.
How can I call things like DisplayAlert, or a function OnRefresh for instance?

Thx for the respons

SjK

part of the code where the ViewCell is defined.

public class textViewCell : ViewCell{
    public textViewCell()
    {
        StackLayout layout = new StackLayout ();
        layout.Padding = new Thickness (15, 0);
        Label label = new Label ();

        label.SetBinding (Label.TextProperty, ".");
        layout.Children.Add (label);

        var moreAction = new MenuItem { Text = "More" };
        moreAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
        moreAction.Clicked += OnMore;

        var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background
        deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
        deleteAction.Clicked += OnDelete;

        this.ContextActions.Add (moreAction);
        this.ContextActions.Add (deleteAction);
        View = layout;
    }

    void OnMore (object sender, EventArgs e)
    {
        var item = (MenuItem)sender;
        //Do something here... e.g. Navigation.pushAsync(new specialPage(item.commandParameter));
        //page.DisplayAlert("More Context Action", item.CommandParameter + " more context action",  "OK");

        //UNTAGGING page.DisplayAlert ...... gives an Error.
        //HOW CAN I DisplayAlert without an Error. 
        //HOW CAN I CALL A RELOAD OF THE PAGE?

    }

    void OnDelete (object sender, EventArgs e)
    {
        var item = (MenuItem)sender;
        interactiveListViewCode.items.Remove (item.CommandParameter.ToString());
    }
}

Viewing all articles
Browse latest Browse all 75885

Trending Articles