Can someone tell me if it's possible to use data binding on
the individual buttons in a ToggleButtonBar and, if so, how?
I want to be able to use data binding for the "enabled"
property of each individual button in the ToggleButtonBar, but
that's not possible using MXML because the ToggleButtonBar takes a
data provider to render the labels of each button and, obviously, I
can't set the "enabled" property on the dataprovider values because
they're not Button objects. For example, I'm not allowed to do
something like this:
Ah! The ToggleButtonBar. Binding. MXML. Mysterious.
Un-obvious. But yes, it CAN be done...
First, you'll need to get at the toggle buttons. Did you know
they are actually ButtonBarButtons? Once you get an instance of
each one, you can do the binding in MXML.
Each LINK button below the ViewStack is bound to a
When you click on a related Button below it, the LINK button
above it will have its enabled property toggled. Then a binding
will fire, setting the related ToggleBarButton's enabled property.
This example requires you to know ahead of time how many
Toggle Buttons and Buttons you have, so it will not scale well.
Each time you add a button, you'd have to hard code it into the
"getButtons" function, which sets up the ButtonBarButton instances.
But if you have a known quantity of buttons, no problem.
I did know the buttons were of type ButtonBarButton, but I
was treating them as type Button as Flex 3 doesn't seem to
recognize the mx.controls.buttonBarClasses package (even though
importing it does work).