Q:

MenuFlyout - code an Item

I just created a small flyout:
MenuFlyout flyout = new MenuFlyout();
flyout.Items.Add(new X_UWP_App.Models.MyMenuFlyoutItem() { Text = "Copy" });
flyout.ShowAt(rect);

I can mark a text. After the marking of the text this flyout appears with "Copy" in it.
Now I wondered how I could put some code behind "Copy"?
I was thinking of something like this, but it does not seem right.
public void onFlyoutItemClick(object sender, FlyoutItemClickEventArgs e)
{
    var dataPackage = new DataPackage();
    dataPackage.SetText(SelGetText());
    Clipboard.SetContent(dataPackage);
}

------ part above got answered. Under this line there is my next related question and answer ----
                var dataPackage = new DataPackage();
                dataPackage.SetText(m_view.vSelGetText());
                Clipboard.SetContent(dataPackage);

This is how those 3 lines really look. Note that m_view.vSelGetText() doesnt work. m_view is not assigned in this class. How could I achieve it so it is assigned. Because right now if I click on "Copy" it copies "Copy". This is the error I get: "An object reference is required for the non-static field, method, or property x.m_view"

A:

You code looks correct, you have implemented MyMenuFlyoutItem, you could add the onFlyoutItemClick in your class like the following.
class MyMenuFlyoutItem : MenuFlyoutItem
{
    public MyMenuFlyoutItem()
    {
        this.Click += MyMenuFlyoutItem_Click;
    }

    private void MyMenuFlyoutItem_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
    {
        var dataPackage = new DataPackage();
        dataPackage.SetText(SelGetText());
        Clipboard.SetContent(dataPackage);
    }

    private string SelGetText()
    {
        return this.Text;
    }
}

