Style triggers in Windows Phone 7
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>
</Imag开发者_开发知识库e.Style>
Is it possible to use datatrigger with windows phone 7 ? What am i doing wrong ?
Thanks ;)
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 of DataTrigger
from somewhere. You can probably pull it out of the Blend SDK.
Why not just databind the imagesource and update that based on (or rather than) IsSelected
?
精彩评论