Forum Xamarin Xamarin.Forms

Best method to hide and show views based on userlevel

BenjaminTooleBenjaminToole USMember ✭✭✭

Hi everyone, what is the appropriate way to hide and show views for instance using someones userlevel in MVVM?

I know that you can change the IsVisible BindableProperty and Bind it to something on the backend, but that seems quite messy. Is there a better way to deal with this?



  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Personally I've never been a fan of the 'levels' scheme. There always seem to be exceptions. For example, everyone that is a 'Supervisor' is allowed to change the employee schedule. Well... Except for Bob. Bob is a supervisor but he abuses the scheduling so we want to take that away from just him.

    I prefer a system of user permissions. currentUser.Permissions.CanEditSchedules , currentUser..Permissions.CanRefundSales , currentUser..Permissions.CanSeeBirthdates etc.

    Then you can just bind directly to those properties on the Permissions of your User.

    But that's just me. Every program is different.

  • BenjaminTooleBenjaminToole USMember ✭✭✭

    Okay cool, but as far as hiding and showing views should I just stick with the IsVisible BindableProperty?

  • BenjaminTooleBenjaminToole USMember ✭✭✭

    For instance Ive been experimenting a lot with DataTemplates and assigning a DataTemplateSelector behind all my pages to select the layout based on some user permission. Not sure if there is a better method out there.

Sign In or Register to comment.