KenEucker
KenEucker

Reputation: 5089

Interactive items in Silverlight Accordion Header

I have an Accordion in my silverlight application, and I am putting textboxes and buttons in the header of the accordion items. It seems as though, because the header catches the click event for expanding the accordion item, it does not propagate that event to the items in the header as well.

Here is my code:

 <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>

Anyone have any ideas of how I can propagate the Click event to the children within the header?

Upvotes: 0

Views: 1333

Answers (1)

Joe McBride
Joe McBride

Reputation: 3777

By default an AccordionItem sets it's ExpanderButton to disabled when it is expanded. This is in the Locked VisualState. If you remove that VisualState you will see that you can indeed click on items within the header when it is selected.

Here is the LockedStates VisualStateGroup of the AccordionItem which you should alter. I can post the whole style if you need, though it's quite verbose.

<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>

Upvotes: 1

Related Questions