2011-05-02 64 views

回答

0

您可以只使用一個Popup,而不是一個點擊後設置爲Popup.IsOpentrue的工具提示。可能需要調整展示位置設置,Popup.StaysOpen可能應該設置爲false

編輯:正如在重複問題中看到的,Tooltip幾乎具有相同的功能。只需要明確處理它。

<DataTemplate> 
    <Image Name="image" MaxHeight="48" Source="{Binding ImgUri}" ToolTipService.IsEnabled="False"> 
     <Image.Triggers> 
      <EventTrigger RoutedEvent="Image.MouseLeftButtonUp"> 
       <BeginStoryboard> 
        <Storyboard> 
         <BooleanAnimationUsingKeyFrames Storyboard.Target="{x:Reference image}" 
                 Storyboard.TargetProperty="ToolTip.IsOpen"> 
          <DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="False"/> 
          <DiscreteBooleanKeyFrame KeyTime="0:0:0.0001" Value="True"/> 
         </BooleanAnimationUsingKeyFrames> 
        </Storyboard> 
       </BeginStoryboard> 
      </EventTrigger> 
     </Image.Triggers> 
     <Image.Resources> 
      <ToolTip x:Key="tip" StaysOpen="False"> 
       <Image Source="{Binding Source={x:Reference image}, Path=Source}"/> 
      </ToolTip> 
     </Image.Resources> 
     <Image.ToolTip> 
      <StaticResource ResourceKey="tip"/> 
     </Image.ToolTip> 
    </Image> 
</DataTemplate> 

注意,toolip自動打開的功能已經通過ToolTipService.IsEnabled="False"

禁用(上面的例子示出了已被點擊在彈出的圖像,沒有大小限制

+0

由於HB的答覆當用戶使用該工具提示時,如果用戶將注意力集中在工具提示上(當用戶將鼠標懸停在工具提示上時),並且只要用戶單擊任何工具提示在2秒後關閉的位置,就可以使用該工具提示。 – 2011-05-03 07:02:51

相關問題