Avg. Rating 4.0

Problem

You want to change the background color of a Flex List control when its enabled property is set to false.

Solution

The following example shows how you can customize the background color of a disabled Flex List control by setting the backgroundDisabledColor style.

Detailed explanation

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/07/17/changing-the-background-color-of-a-disabled-list-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
 
    <mx:Array id="arr">
        <mx:Object label="One" />
        <mx:Object label="Two" />
        <mx:Object label="Three" />
        <mx:Object label="Four" />
        <mx:Object label="Five" />
        <mx:Object label="Six" />
        <mx:Object label="Seven" />
        <mx:Object label="Eight" />
        <mx:Object label="Nine" />
        <mx:Object label="Ten" />
    </mx:Array>
 
    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="enabled:">
                <mx:CheckBox id="checkBox"
                        selected="true" />
            </mx:FormItem>
            <mx:FormItem label="backgroundDisabledColor:">
                <mx:ColorPicker id="colorPicker"
                        selectedColor="0xDDDDDD" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>
 
    <mx:List id="list"
            dataProvider="{arr}"
            enabled="{checkBox.selected}"
            width="200"
            backgroundDisabledColor="{colorPicker.selectedColor}" />
 
</mx:Application>

For more information, see "Changing the background color of a disabled List control in Flex" at FlexExamples.com.

Report abuse

Related recipes