Search code examples
mvvmxamarin.iosxamarinmvvmcross

MvvmCross: How to bind to visibility of UIBarButtonItem?


I have a view in iOS that needs to be displayed in two modes, one with a close button in the navigation header and one without a close button. I added a bool in my viewmodel to handle this. However, a UIBarButtonItem does not have a Hidden property to bind to this bool in my viewmodel. Any suggestions on how to address this problem? NOTE: I do NOT need to change the visibility of this close button at runtime. This is just an initial read-only setting I need before the view is displayed.


Solution

  • For static setup, you can just try inspecting a viewmodel property in your ViewDidLoad code.

    For creating custom bindings, see https://speakerdeck.com/cirrious/custom-bindings-in-mvvmcross