您的位置:首页 > 其它

来自Stormer 大虾的WPF学习资料,分享给已经学习或即将学习的童鞋们

2009-10-27 16:36 351 查看
原帖为:http://stormer008.blog.sohu.com/135059627.html

转帖请注明

以下为原帖内容,未作任何更改

这么简单的一个功能,费了好久才搞定,感谢那些冷漠的“WPF高手”,给我一个自己思考摸索的机会。

好了,现在我就把我实现的方法写给大家。

我是用控件模板和模板控件的触发器来实现鼠标滑过按钮变化图片(我用的PNG图片)的,也许还有其他的方法可以实现,如果你知道了请留言给我。

首先,在APP.XAML中定义一个控件模板,代码如下:

<Application x:Class="DynamicOutput.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="win_main.xaml">

<Application.Resources>

<ResourceDictionary>

<ControlTemplate x:Key="temp_b_top_close" TargetType="{x:Type Button}">

<Image Name="Image" Source="./images/b0.png" Width="32" Height="18"/>

<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Image" Property="Source" Value="./images/b1.png"/>
</Trigger>
</ControlTemplate.Triggers>

</ControlTemplate>

</ResourceDictionary>

</Application.Resources>
</Application>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐