Bind to property with argument?

May 11, 2011 at 7:48 PM

I have a dynamically generated menu that renders a list of re-styled radio buttons. Each menu item object (called SideMenuItem) has a collection of screen names. This collection tells the radiobutton whether or not it should be checked, depending on the currently active screen.

So what I need is a property similar to this:

 

        public bool IsMenuItemActive(SideMenuItem smi)
        {
            get
            {
                if(smi.ScreenContainer.Contains(activeScreenName()))
                    return true;
                else
                    return false;
            }
        }

However, that is not valid. You can't have arguments for a Parameter (or at least I don't know how). I need each bound menu item to bind the IsChecked property to a method similar to this, but I need to know which SideMenuItem is calling the parameter. I hope this is clear enough. Any ideas how to achieve this?

 

May 11, 2011 at 8:37 PM

Can't your SideMenuItem have an IsActive property by itself? Or did I misunderstood your scenario? 

May 12, 2011 at 2:22 PM

That's exactly what I needed to do. Thanks!