Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Binding Object in ViewCell

$
0
0

I am trying to implement context actions in my viewcells. I'd like to add two different menu actions based on a property of the object binded in the view cells. I have a listview of objects, when i select one of them, I would like to show one menu item or the other. But I don't know how to get this.

I thought to use protected override void OnBindingContextChanged () and get the object in this way:
protected override void OnBindingContextChanged ()
{
base.OnBindingContextChanged ();
myObject = (MyObject)BindingContext;

            if(myObject.myproperty)
                ContextActions.add(action1);
            else
                ContextActions.add(action2);
    }

is this the right way?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>