Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Add ToolbarItem in Xamarin.Forms with F#

My Xamarin.Forms project contains PCL in F#. I want to add ToolbarItem on the page which navigate to some other page. How should it be done?

With my code, error comes that "The value or constructor 'this' is not defined".

This is my code:

type SomePage() = 
    inherit ContentPage()

    let _ = base.LoadFromXaml(typeof<SomePage>)

    let toolbarItem = new ToolbarItem("O", "icon", (fun() -> this.Navigation.PushAsync(OtherPage())), ToolbarItemOrder.Default, 0)
    do base.ToolbarItems.Add(toolbarItem)


  • Gigex42Gigex42 USMember ✭✭✭✭

    Within you function when the toolbaritem got activated you use this.navigation... Just delete the 'this'? I dont know what the self identifier for F# is.

  • MauliShahMauliShah INMember

    Navigation can be accessed with this or base only in F#, so I can't do it without it.

  • fbmndsfbmnds Member
      type SomePage() as this =
Sign In or Register to comment.