Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to setup bindingcontext in xaml?

Hello,

I usualy setup the binding in the view in this way:

_viewModel = new UserPageViewModel(mgr);
BindingContext = _viewModel;

What is the same command in the xaml?

The following is not working:

Can someone help?

Tagged:

Best Answer

Answers

  • russferns22russferns22 Member ✭✭
    edited September 2018

    @chris00r add the following lines of code to your views xaml and carry out your binding

    <ContentPage.BindingContext>
        <ViewModel:className/>
    </ContentPage.BindingContext>
    
  • batmacibatmaci DEMember ✭✭✭✭✭

    @jezh is there any performance difference between setting in xaml vs code?

  • igorkr_10igorkr_10 Member ✭✭✭✭

    @batmaci said:
    @jezh is there any performance difference between setting in xaml vs code?

    On my opinion there is no difference if we use [XamlCompilation(XamlCompilationOptions.Compile)]

Sign In or Register to comment.