Search code examples
xamarin.iosmvvmcross

MVVMCross & Xamarin.ios - Anchoring a menu to the previous Views Button


I am using MVVMCross along with Xamarin in my iOS app. I want to implement a popover menu that is activated when a button is clicked (see image below). I have a homeview for my table and menuview for the menu (with an associated MvxViewModel for each). All standard stuff.

What I am struggling with is how to pass the anchor point (i.e. the top right button) from the homeview to the menuview.

Any pointers in the right direction would be great. Thanks

enter image description here


Solution

  • After reading and re-reading the commit comments for the feature at MvvmCross I realised I needed to add the following code to the home view:

    var provider = Mvx.IoCProvider.Resolve<IMvxPopoverPresentationSourceProvider>();
    provider.SourceView = CategoryLabel;
    

    The above anchors the popover to the Category Label.