WP8 上触发器的替代方案 [英] Alternative to Triggers on WP8

查看:34
本文介绍了WP8 上触发器的替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到,WP8 的 XAML 不支持 Triggers.什么是替代方法?我想使用触发器在点击时更改按钮的背景图像.

I've read that Triggers are not supported in XAML for WP8. What's the alternative approach? I wanted to use a trigger to change the background image of a button when tapped.

推荐答案

请试试这个.Windows 手机触发 msdn

Please try this. Windows phone triggers msdn

这里我将图像数据触发器与我的 Boolean 属性绑定,当 Boolean 属性更改时,它将触发并且 setter 将触发.确保您的属性使用 INofityPropertyChanged

Here I binded the image data trigger with my Boolean property , when the Boolean property is changed it will trigger and the setter will fire. Make sure you properties are implemented with INofityPropertyChanged

 xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" x:Class="XXX_XXXX"
<Image Source="/Assets/Images/Tick.png"
                   Stretch="None"
                   HorizontalAlignment="Stretch" 
                   VerticalAlignment="Top">
                <interactivity:Interaction.Triggers>
                    <ec:DataTrigger Binding="{Binding IsTapped}" Value="True">
                        <ec:ChangePropertyAction PropertyName="Source">
                            <ec:ChangePropertyAction.Value>

                                <BitmapImage UriSource="/Assets/Images/Close.png"/>
                            </ec:ChangePropertyAction.Value>
                        </ec:ChangePropertyAction>
                    </ec:DataTrigger>
                </interactivity:Interaction.Triggers>
            </Image>

这篇关于WP8 上触发器的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆