Windows Phone 7 中的样式触发器
我想使用 Windows Phone 7 中的样式触发器来根据布尔变量更改图像的源。
我想做这样的事情:
<Image Source="/Century21;component/Images/appbar.favs.addto.rest.png" Name="IconButtonSelection">
<Image.Style>
<Style TargetType="Image">
<Setter Property="Source" Value="/Century21;component/Images/appbar.favs.addto.rest.png"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="True">
<Setter Property="Source" Value="/Century21;component/Images/appbar.check.rest.png"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
是否可以在 Windows Phone 7 中使用 datatrigger? 我做错了什么?
谢谢 ;)
I want to use the style triggers in Windows Phone 7 to change the source of an image depending a boolean variable.
I Wann do something like this :
<Image Source="/Century21;component/Images/appbar.favs.addto.rest.png" Name="IconButtonSelection">
<Image.Style>
<Style TargetType="Image">
<Setter Property="Source" Value="/Century21;component/Images/appbar.favs.addto.rest.png"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="True">
<Setter Property="Source" Value="/Century21;component/Images/appbar.check.rest.png"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
Is it possible to use datatrigger with windows phone 7 ?
What am i doing wrong ?
Thanks ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Silverlight 3(WP7 框架所基于的)不支持样式触发器。您可以将触发器应用于
Image
元素本身而不是样式,但您需要从某处获取DataTrigger
的实现。您或许可以将其从 Blend SDK 中提取出来。Silverlight 3 (on which the WP7 framework is based) doesn't support style triggers. You could apply a trigger to the
Image
element itself instead of the style, but you'd need to get hold of an implementation ofDataTrigger
from somewhere. You can probably pull it out of the Blend SDK.为什么不直接对图像源进行数据绑定并根据(或不是)
IsSelected
进行更新?Why not just databind the imagesource and update that based on (or rather than)
IsSelected
?