问题描述
我正在使用Silverlight 4和VS2010.
我有一个带有ItemsControl的StackPanel.
它的ItemTemplate已绑定到其各自的DataTemplate.
它充满了几个扩展器,每个扩展器中都有大量数据.
每当我扩展其中一个扩展器时,我都希望折叠所有剩余的扩展器.
在我的项目的另一部分,我有一个类似的结构,其中扩展器是硬编码的.
为了获得相同的结果,我只需遍历StackPanel.Children集合并使用foreach桩,然后折叠所有Expander.
使用Stackpanel和ItemsControl不能做到这一点,因为ItemsControl是Stackpanel.Children上的唯一子项.
任何人都可以帮助我如何使用后面的C#代码访问每个扩展器并将其折叠起来?
Hi,
I''m using Silverlight 4 and VS 2010.
I have a StackPanel with a ItemsControl.
It''s ItemTemplate is binded to it''s respective DataTemplate.
It is filled with a few Expanders with a lot of data in each one.
Whenever I expand one of these Expanders I want to collapse all the remaining Expanders.
On another part of my project I have a similar structure where the Expanders are hard coded.
To achieve the same result I just go through the StackPanel.Children collection with a foreach cicle and collapse all the Expanders.
Using a Stackpanel and an ItemsControl I can''t do that because the Itemscontrol is the only child on the Stackpanel.Children.
Can anyone help on how do I get to each of the Expanders using c# code behind and collapse them?
<DataTemplate x:Key="AvaliacaoDataTemplate">
<Grid>
<toolkit:Expander x:Name="ExpanderAvaliacao" Header="{Binding}" d:LayoutOverrides="Width, Height" HeaderTemplate="{StaticResource AvaliacaoDataTemplateHeader}" Style="{StaticResource StyleExpanderBlue3}" Expanded="Expander_Expanded">
<StackPanel>
<!-- Lots of stuff -->
</StackPanel>
</toolkit:Expander>
</Grid>
</DataTemplate>
<StackPanel x:Name="Avaliacoes">
<ItemsControl x:Name="ItemsAvaliacao" ItemTemplate="{StaticResource AvaliacaoDataTemplate}"/>
</StackPanel>
我真的需要对此问题有所了解!
有人吗?!!
谢谢.
I really need some light on this issue!
Anyone?!!
Thanks.
推荐答案
这篇关于有关ItemsControl Expander操作的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!