我想制作一个工具提示,在几秒钟的用户关注之后会自我扩展.
不知道如何准确地描述这一点,但得到了一个完美的例子.这是AutoCAD Architecture 2014中使用的工具提示.当我将鼠标移到任何按钮上时,会出现典型的工具提示.但是在这里按住鼠标2-3秒后,工具提示会将自身扩展为更大的一个.以下是截图前后:
之前:
后:
还有我的一些测试代码.两个按钮,一个带有标准工具提示,我想要在开头,第二个带有扩展内容.如何将其转换为一个?
<StackPanel>
<Button Content="Advanced" Height="50" Width="150" TextBlock.FontSize="20">
<Button.ToolTip>
<TextBlock Text="Test"/>
</Button.ToolTip>
</Button>
<Button Height="50" Width="150" Content="Advanced 2" TextBlock.FontSize="20">
<Button.ToolTip>
<StackPanel Height="200" Width="200">
<StackPanel Height="30" Width="200" Orientation="Horizontal"/>
<Image VerticalAlignment="Top" Width="30" Height="30" Source="C:\tmp\ask.png" Name="image1"/>
<TextBlock Text="Here will be some more text."/>
</StackPanel>
</Button.ToolTip>
</Button>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
最后一个,如何在转换工具提示的同时进行"扩展"转换?
尝试使用延迟显示控件的自定义样式。
<Window.Resources>
<Style TargetType="Image" x:Key="DelayShowImage">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsVisible, RelativeSource={RelativeSource AncestorType=StackPanel}}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard x:Name="VisibleStory">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
Duration="0"
BeginTime="0:0:02">
<DiscreteObjectKeyFrame Value="{x:Static Visibility.Visible}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<RemoveStoryboard BeginStoryboardName="VisibleStory"/>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<Button Content="Advanced" Height="50" Width="150" TextBlock.FontSize="20">
<Button.ToolTip>
<TextBlock Text="Test"/>
</Button.ToolTip>
</Button>
<Button Height="50" Width="150" Content="Advanced 2" TextBlock.FontSize="20">
<Button.ToolTip>
<StackPanel Height="200" Width="200">
<StackPanel Height="30" Width="200" Orientation="Horizontal"/>
<Image VerticalAlignment="Top" Width="30" Height="30" Source="C:\tmp\ask.png" Name="image1"
Style="{StaticResource DelayShowImage}"/>
<TextBlock Text="Here will be some more text."/>
</StackPanel>
</Button.ToolTip>
</Button>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
上面的代码在第二个按钮中显示工具提示,并在 2000 毫秒(0:0:02)后显示图像。您可以更改要稍后显示的不同控件所使用的样式。
| 归档时间: |
|
| 查看次数: |
245 次 |
| 最近记录: |