Forum Xamarin.Forms

FreshMVVM access PageModel from Page code behind

MCvelMCvel USMember ✭✭✭

Hi all,

does anybody knows how to access the PageModel from the Page code behind?

I already tried using this:

var pageModel = BindingContext as SamplePageModel;

however I always get my pageModel = null,

the thing is that I need to bind some TapGestureRecognizer to some methods/commands in my PageModel,

thank you all,


Best Answer


  • jbravobrjbravobr BRMember ✭✭
    edited July 2016

    Hi @MCvel,

    Is your VM inheriting from FreshBasePageModel ?

    Are you keep the FreshMvvm pattern for directories? As for Pages the directory name MUST BE Pages and for PageModels MUST BE PageModels ?

    Are you keep the FreshMvvm pattern for name of your View Models and Pages ? For Views Models MUST BE xptoPageModel and for Pages xptoPage.

    My guess is that the name pattern was not applied.

  • MCvelMCvel USMember ✭✭✭

    @jbravobr yes, the naming convention is properly configured, I actually have working some controls binded in XAML. Thanks!

    @RobHeckart that did the trick, thanks man!

Sign In or Register to comment.