1

您好,感谢您的帮助。我有一个使用分层数据模板填充的 Treeview,并且当前底部节点有一个工具提示,该工具提示生成一个小的堆栈面板,其中填充了特定于鼠标悬停的项目的数据。我在工具提示中也有一个按钮,但是,当鼠标移到它上面时,工具提示不会持续存在,我无法像我需要的那样使用按钮。我的 xml 看起来像这样:

<!--===========================  Hierarchical Data template  for tree view -->
                        <!--template for bottom nodes-->
                        <sdk:HierarchicalDataTemplate x:Key="ModTemplate" ItemsSource="{Binding ApplicationModules}">
                            <StackPanel Orientation="Horizontal" >                            <!--======tooltip style to handle format for callout window============-->
                                <ToolTipService.ToolTip>
                                    <ToolTip  HorizontalOffset="0" VerticalOffset="0" Style="{StaticResource ModuleToolTipStyle}">

                                        <StackPanel Width="150" Height="auto" >
                             <TextBlock Text="Module Info" FontWeight="Bold" TextAlignment="Center"/>
                                            <TextBlock Text="Module State:" FontWeight="Bold" />
                                            <TextBlock Text="{Binding Path=ModInfo.ModuleState}" />
                                            <TextBlock Text="Module Start Time:" FontWeight="Bold" />
                                            <TextBlock Text="{Binding Path=ModInfo.ModuleStartTime}"/>
                                            <TextBlock Text="Module Down Time:" FontWeight="Bold"/>
                                            <TextBlock Text="{Binding Path=ModInfo.ModuleDownTime}" />
                                            <Button Content="More Info" Width="75"></Button>
                                        </StackPanel>

                                    </ToolTip>
                                </ToolTipService.ToolTip>
               <!--============end tooltip style for callout window===================-->

                                <ContentPresenter Margin="0 0 4 0" Content="{Binding Icon}" />
                                <TextBlock FontStyle="Italic" Text="{Binding Path=ModuleName}" />
                            </StackPanel>
                        </sdk:HierarchicalDataTemplate>

我希望当鼠标移过它时工具提示仍然存在,以便我可以将事件连接到按钮。我怎样才能做到这一点?再次感谢您的帮助。

4

1 回答 1

1

你有几个选择来实现你的目标,我知道。您可以在 codeplex 上查看Silverlight Advanced Tooltips项目,该项目可以满足您的需求(尽管我个人没有使用过它,因此无法给出任何评论。)

或者你可以用一些创造力自己制作。如果是我,我可能会跳过所有这些乱七八糟的东西,忘记 ToolTipService 一起做我自己的打扮,因为对于用户来说,你提供的不是他们习惯的工具提示无论如何都期望,并且更多地涉及标注或弹出功能。如果选项 #1 对您不起作用,我可以在腾出一些时间后立即举个例子,但我希望它可以。本质上,我的方式和我提供的项目链接都会做同样的事情,即在它所附加的 MouseLeave 事件之后提供延迟,以便用户可以在它消失之前到达它。然后将其可见性条件传递给该对象。如果这不起作用,请告诉我,我可以为您提供一个仅使用 XAML 的替代示例。

于 2012-08-16T20:08:17.657 回答