Forum Xamarin.Forms

Toolbar Command Binding Problem Xaml

S_Olias_SS_Olias_S DEMember ✭✭
edited March 2016 in Xamarin.Forms

i´m trying to Bind a toolbaritem but unfortunatly, when i press "Add" nothing happens.


<ToolbarItem Text="Add" Command="{Binding AddTicketCommand}" />


public Toolbartest(){
     AddTicketCommand = new Command(GotoAddTicket);
    public ICommand AddTicketCommand { set; get; }

    private async void GotoAddTicket()
        await navigation.PushModalAsync(new AddTicketPage());

Best Answer


  • JulienRosenJulienRosen CAMember ✭✭✭✭

    Examine your output window for binding errors at runtime. From the code you posted, it doesn't look like you are assigning a BindingContext. Your page that contains the ToolbarItem needs to have as its BindingContext an instance of a class that has the AddTicketCommand.

  • S_Olias_SS_Olias_S DEMember ✭✭
    edited March 2016

    Sry i forgot to add this to the question.
    Her you can see how i Bind the ViewModel.
    <ContentPage .....


    *AppName:Toolbartest />

    *< deltete because of the website....

  • JulienRosenJulienRosen CAMember ✭✭✭✭

    That is not how you bind anything at all.

    Generally I do it in the constructor of my page
    BindingContext = new MyViewModel();

Sign In or Register to comment.