当前位置:编程学习 > asp >>

WPF-004 控件 ToolTip

WPF中的工具提示(鼠标放在某个控件上弹出的那个东东)用法很简单。
1、复杂的工具提示
不光有文字还有图片什么的,只需要使用ToolTip属性,给该属性中加控件就可以了。如下,
 [html]  
<!--复杂的工具提示-->  
        <Button Height="25" Content="提示工具演示" HorizontalAlignment="Center">  
            <Button.ToolTip>  
                <ToolTip Background="#60AA4030" Foreground="White" HasDropShadow="False"  
                          Placement="Mouse">  
                    <StackPanel>  
                        <TextBlock Margin="3">提示语:这是什么?</TextBlock>  
                        <Image Source="Image/kengdiede12306.jpg" Stretch="Fill"/>  
                        <TextBlock Margin="3">传说中的3亿网站。</TextBlock>  
                    </StackPanel>  
                </ToolTip>  
            </Button.ToolTip>  
        </Button>  
 
<!--复杂的工具提示-->
        <Button Height="25" Content="提示工具演示" HorizontalAlignment="Center">
            <Button.ToolTip>
                <ToolTip Background="#60AA4030" Foreground="White" HasDropShadow="False"
                          Placement="Mouse">
                    <StackPanel>
                        <TextBlock Margin="3">提示语:这是什么?</TextBlock>
                        <Image Source="Image/kengdiede12306.jpg" Stretch="Fill"/>
                        <TextBlock Margin="3">传说中的3亿网站。</TextBlock>
                    </StackPanel>
                </ToolTip>
            </Button.ToolTip>
        </Button>效果:\
 
至于修改提示的位置,一般修改Placement属性。
2、纯文本的提示
这个就不需要加控件了,直接写在toolTip属性里了。
 
 
[html]  
<Button Width="200"  Height="50" Content="ToolTip属性演示" Grid.Row="2"  
        ToolTip="纯文本TollTip就用这个啦。" HorizontalAlignment="Center">  
</Button>  
 
        <Button Width="200"  Height="50" Content="ToolTip属性演示" Grid.Row="2"
                ToolTip="纯文本TollTip就用这个啦。" HorizontalAlignment="Center">
        </Button>效果:
\
3、不能使用ToolTip属性的
如果有控件没有ToolTip属性,那么就用ToolTipService属性了。
 
[html]  
<Button Width="200" Height="50" Grid.Row="1" Content="ToolTipService演示"  
        HorizontalAlignment="Center" ToolTipService.InitialShowDelay="1"  
        ToolTipService.ToolTip="ToolTipService">  
</Button>  
 
        <Button Width="200" Height="50" Grid.Row="1" Content="ToolTipService演示"
                HorizontalAlignment="Center" ToolTipService.InitialShowDelay="1"
                ToolTipService.ToolTip="ToolTipService">
        </Button>效果:
 
\
补充:Web开发 , ASP.Net ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,