Silverlight AccordionItem HeaderTemplate 中的超链接

发布于 2024-10-11 17:04:55 字数 940 浏览 2 评论 0原文

我为我的手风琴创建了一个 HeaderTemplate,我想在标题的一侧显示一个文本块,在右侧显示一个超链接。显示工作正常,但是当用户单击时不会调用单击事件,我猜测 b/c 标题本身正在捕获展开/收缩的单击。

    <layoutToolkit:Accordion>
        <layoutToolkit:AccordionItem IsSelected="True">
            <layoutToolkit:AccordionItem.HeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Height="20">
                        <TextBlock Margin="0,0,700,0">Cancel Postcards</TextBlock>                                  
                          <HyperlinkButton Content="Next Call" Foreground="Blue" Click="NextCancel_Click" />
                      </StackPanel>
                  </DataTemplate>
            </layoutToolkit:AccordionItem.HeaderTemplate>
..... more code ....

有没有办法让超链接响应事件而无需实际创建新控件?

更新:看起来标题在展开时将所有子控件设置为禁用,这就是链接不起作用的原因。当您折叠该手风琴项目时它就会起作用。那么,现在的问题是,如何防止超链接被禁用?

I have created a HeaderTemplate for my accordions where I want to display a text block on one side of the header and a hyperlink on the right side. The display is working correctly, but the click event is not called when the user clicks, I'm guessing b/c the header itself is trapping the click for expand/contract.

    <layoutToolkit:Accordion>
        <layoutToolkit:AccordionItem IsSelected="True">
            <layoutToolkit:AccordionItem.HeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Height="20">
                        <TextBlock Margin="0,0,700,0">Cancel Postcards</TextBlock>                                  
                          <HyperlinkButton Content="Next Call" Foreground="Blue" Click="NextCancel_Click" />
                      </StackPanel>
                  </DataTemplate>
            </layoutToolkit:AccordionItem.HeaderTemplate>
..... more code ....

Is there a way to get the hyperlink to respond to events without practically creating a new control?

Update: It looks like the header sets all child controls to disabled when expanded which is why the link doesnt work. It will work when you collapse that accordionitem. So, the question now is, how do i prevent the hyperlink from being disabled?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

铁轨上的流浪者 2024-10-18 17:04:55

嘿查理,我刚刚在 Epic720 上回答了同样的问题。您必须更改锁定的视觉状态。

Silverlight Accordion 标头中的交互式项目

这是 LockedStates VisualStateGroup您应该更改的 AccordionItem。如果您需要,我可以发布整个样式,尽管它非常冗长。

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

Hey Charlie, I just happened to answer this same question for Epic720. You have to change the Locked VisualState.

Interactive items in Silverlight Accordion Header

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文