如何使用 vslider 作为列表的滚动条?
如何使用 vslider 作为列表的滚动条?我已经得到了这个,但无法从这里弄清楚:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark" height="100%" width="100%">
<s:VSlider id="slider" minimum="0" maximum="{listy.height}" liveDragging="true"/>
<s:List id="listy" width="50%" height="100">
<s:layout>
<s:VerticalLayout id="vLayout" verticalScrollPosition="{slider.value}" />
</s:layout>
<mx:ArrayCollection>
<fx:String>Flash</fx:String>
<fx:String>Director</fx:String>
<fx:String>Dreamweaver</fx:String>
<fx:String>ColdFusion</fx:String>
<fx:String>Flash</fx:String>
<fx:String>Director</fx:String>
<fx:String>Dreamweaver</fx:String>
<fx:String>ColdFusion</fx:String>
<fx:String>Flash</fx:String>
<fx:String>Director</fx:String>
<fx:String>Dreamweaver</fx:String>
<fx:String>ColdFusion</fx:String>
</mx:ArrayCollection>
</s:List>
</s:Application>
编辑:使用下面的内特的建议,我现在已经让它工作了,但它显示了 vslider 以及默认滚动条。如何隐藏默认滚动条?我尝试设置verticalScrollPolicy =“off”,但这不起作用。谢谢
how do I use a vslider as the scrollbar for a list? I've got this, but can't figure it out from here:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark" height="100%" width="100%">
<s:VSlider id="slider" minimum="0" maximum="{listy.height}" liveDragging="true"/>
<s:List id="listy" width="50%" height="100">
<s:layout>
<s:VerticalLayout id="vLayout" verticalScrollPosition="{slider.value}" />
</s:layout>
<mx:ArrayCollection>
<fx:String>Flash</fx:String>
<fx:String>Director</fx:String>
<fx:String>Dreamweaver</fx:String>
<fx:String>ColdFusion</fx:String>
<fx:String>Flash</fx:String>
<fx:String>Director</fx:String>
<fx:String>Dreamweaver</fx:String>
<fx:String>ColdFusion</fx:String>
<fx:String>Flash</fx:String>
<fx:String>Director</fx:String>
<fx:String>Dreamweaver</fx:String>
<fx:String>ColdFusion</fx:String>
</mx:ArrayCollection>
</s:List>
</s:Application>
EDIT: Using Nate's suggestion below, I've now got it working but it shows both the vslider as well as the default scrollbar. How do I hide the default scrollbar? I tried setting verticalScrollPolicy="off" but that didn't work. thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是完全可能的,我的目标是证明这一点!不开玩笑了,这里只是一些简单的绑定,你已经非常接近了!
如果您不明白其方式和原因,请联系我:)
It's totally possible, and I aims to proove it! All joking aside, here it is working with just some simple binding, you were very close!
Ping me if you don't get the how and why of it :)
我建议您实现目标的最佳方法是剥皮。为
VScrollBar
创建外观,其外观与VSlider
相同。然后创建自定义Scroller
皮肤(采用spark.skins.spark.ScrollerSkin
作为模式)并在那里分配这些滚动条皮肤。然后创建自定义List
皮肤(基于spark.skins.spark.ListSkin
)并将Scroller
皮肤分配给Scroller那里。
如果您(由于某种原因)必须使用原始的
VSlider
,您需要编写自己的带有滑块的Scroller
并在您的List< 中使用它/代码> 皮肤。
我建议你第一种方法。
The best way I can suggest you to reach your goal is skinning. Create a skin for
VScrollBar
which looks the same asVSlider
. Then create customScroller
skin (takespark.skins.spark.ScrollerSkin
as a pattern) and assign these scroller skins there. Then create your customList
skin (based onspark.skins.spark.ListSkin
) and assignScroller
skin to theScroller
there.In the case if you (for some reason) have to use original
VSlider
you'll need to write your ownScroller
with sliders and use it in yourList
skin.I suggest you the first method.
不幸的是,我不相信如果不进行重大返工这是可能的。
该列表在 ListSkin 内部作为 Scroller 和 DataGroup 实现。
Scroller 有两个外观部分:verticalScrollBar 和horizontalScrollBar。您想用 VSlider 替换 veritcalScrollBar。
不幸的是,皮肤需要一个 VScrollBar 实例,并且没有可以用来替换另一个的接口类。 (Scroller 实现是使用 Flex 2/3 方法实现的,以便使其难以扩展)
您必须使用黑魔法来完成这项工作。
然而,尝试将 VSCrollBar 的外观设置为 VSlider 似乎确实是您最好的选择。
Unfortunately, I do not believe this is possible without significant rework.
The list is implemented, inside the ListSkin, as a Scroller and a DataGroup.
The Scroller has two skin parts, the verticalScrollBar and the horizontalScrollBar. You want to replace the veritcalScrollBar with a VSlider.
Unfortunately, the skin requires a VScrollBar instance and there is no interface class you can use to replace one with the other. (The Scroller implementation was implemented using the Flex 2/3 approach in order to make it impossibly hard to extend)
You're stuck using black magic to make this work.
However, trying to skin the VSCrollBar to look like a VSlider does seem to be like your best bet.