Removing the border skin on a List control in Flex

by Peter deHaan on February 2, 2009

in List

The following example shows how you can remove the border skin on a Flex List control by setting the borderSkin style to null using MXML, CSS, and ActionScript.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/02/02/removing-the-border-skin-on-a-list-control-in-flex/ -->
<mx:Application name="List_borderSkin_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:List id="list"
            dataProvider="[Red,Orange,Yellow,Green,Blue]"
            borderSkin="{null}"
            width="100" />

</mx:Application>

You can also set the borderSkin style in an external .CSS file or <Style> block, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/02/02/removing-the-border-skin-on-a-list-control-in-flex/ -->
<mx:Application name="List_borderSkin_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Style>
        List {
            borderSkin: ClassReference(null);
        }
    </mx:Style>

    <mx:List id="list"
            dataProvider="[Red,Orange,Yellow,Green,Blue]"
            width="100" />

</mx:Application>

Or, you can set the borderSkin style using ActionScript, as seen in the following example:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/02/02/removing-the-border-skin-on-a-list-control-in-flex/ -->
<mx:Application name="List_borderSkin_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            private function init():void {
                list.setStyle("borderSkin", null);
            }
        ]]>
    </mx:Script>

    <mx:List id="list"
            dataProvider="[Red,Orange,Yellow,Green,Blue]"
            width="100"
            initialize="init();" />

</mx:Application>

{ 4 comments… read them below or add one }

1 Robert April 16, 2009 at 8:26 pm

Thank you for posting this!
I had to restyle an entire app for a client and couldn’t find this anywhere. I began extending the list class to do this but decided to search around one more time.

Reply

2 Robin September 24, 2009 at 7:08 am

I’m using spark.components.list and for this the borderSkin does not exist…. Hence I get a compile error. Do you have any solution for this?

Reply

3 Peter deHaan September 24, 2009 at 8:46 am

@Robin,

The mx.controls.List and spark.components.List are completely different controls with different APIs. You’d modify the Spark List control’s appearance by creating a custom skin instead. For more information on the Halo/MX and Spark controls, see the beta Flex 4 Language Reference at http://livedocs.adobe.com/flex/gumbo/langref/.

Peter

Reply

4 Reshma February 3, 2010 at 3:15 pm

Is there a way to remove the List border highlight that happens when an item is dragged out or into a List?

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: