2013-02-12 68 views
0

有没有办法通过Accordion headerRenderer发现哪个孩子被选中?哪个手风琴儿童被选中?

我使用flexlib中的CanvasButtonAccordionHeader,我只想在selectedChild的头部中显示组件。

感谢您的任何有用的提示。

回答

1

您可以使用定义内联headerRenderer并使用outerDocument属性。 这是一个例子:

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:ns="http://code.google.com/p/flexlib/"> 
    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 

    <mx:Accordion id="acc" width="400" height="400" headerHeight="40"> 
     <mx:headerRenderer> 
      <fx:Component> 
       <ns:CanvasButtonAccordionHeader label="{'selected ' +outerDocument.acc.selectedChild.label}"> 
       </ns:CanvasButtonAccordionHeader> 
      </fx:Component> 
     </mx:headerRenderer> 
     <mx:Canvas label="Personal" toolTip="Child number one"> 
      <mx:Label text="Contents of Child 1" /> 
     </mx:Canvas> 
     <mx:Canvas label="Accounts" toolTip="Child number two"> 
      <mx:Label text="Contents of Child 2" /> 
     </mx:Canvas> 
     <mx:Canvas label="Help" toolTip="Child number three"> 
      <mx:Label text="Contents of Child 3" /> 
     </mx:Canvas> 
    </mx:Accordion> 
</s:Application> 

达维德

+0

这肯定会工作,谢谢。但是如果我不使用内联标题渲染器呢? – fumeng 2013-02-13 19:14:21