Style triggers in Windows Phone 7

别等时光非礼了梦想. 提交于 2019-12-20 02:59:24

问题


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 ;)


回答1:


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.




回答2:


Why not just databind the imagesource and update that based on (or rather than) IsSelected?



来源:https://stackoverflow.com/questions/5647557/style-triggers-in-windows-phone-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!