我的Silverlight应用程序中有一个Accordion,我在手风琴项目的标题中放置了文本框和按钮。好像是因为标题捕获了click事件以扩展accordion项目,所以它也不会将该事件传播到标题中的项目。
这是我的代码:
<toolkit:Accordion Height="27" HorizontalAlignment="Left" Name="accordion1" VerticalAlignment="Top" Width="400">
<toolkit:AccordionItem>
<toolkit:AccordionItem.Header>
<toolkit:WrapPanel>
<sdk:Label Content="Program" Width="42" FontSize="13" />
<sdk:Label Content="Prog" Width="42" FontSize="13" />
<sdk:Label Content="Start:" />
<TextBox Width="45"></TextBox>
<sdk:Label Content="End:" />
<TextBox Width="45"></TextBox>
<sdk:Label Content="Total:" />
<sdk:Label Content="Total time: " Width="91" />
<Button Click="delete_Click" Content="X" ></Button>
</toolkit:WrapPanel>
</toolkit:WrapPanel>
</toolkit:AccordionItem.Header>
<my:SetlistConfigurator />
</toolkit:AccordionItem>
</toolkit:Accordion>
任何人都有任何关于如何将Click事件传播到标题中的子项的想法吗?
答案 0 :(得分:1)
默认情况下,AccordionItem在展开时将ExpanderButton设置为禁用。这是在Locked VisualState中。如果删除该VisualState,您将看到在选择它时,您确实可以单击标题中的项目。
这是您应该更改的AccordionItem的LockedStates VisualStateGroup。如果你需要,我可以发布整个风格,虽然它很冗长。
<VisualStateGroup x:Name="LockedStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Locked">
<Storyboard>
<!--
<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="IsEnabled" Storyboard.TargetName="ExpanderButton">
<DiscreteObjectKeyFrame KeyTime="0" Value="False"/>
</ObjectAnimationUsingKeyFrames>
-->
</Storyboard>
</VisualState>
<VisualState x:Name="Unlocked">
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="IsEnabled" Storyboard.TargetName="ExpanderButton">
<DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>