Silverlight/WP7:以编程方式更改按钮背景图像 [英] Silverlight/WP7: programmatically change the button background image

查看:27
本文介绍了Silverlight/WP7:以编程方式更改按钮背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<Button x:Name="BtnSearch" Height="120" Width="120" Margin="-20,-30,0,0" Click="BtnSearch_Click" BorderThickness="0" BorderBrush="{x:Null}" Visibility="Visible" >
                <Button.Background>
                    <ImageBrush x:Name="searchImage" ImageSource="images\appbar.feature.search.rest.png" Stretch="Fill"/>
                </Button.Background>

在上面的 xaml 中,我必须以编程方式将图像源更改为不同的图像.我该怎么做 ?

In the above xaml I have to change the imagesource programmatically to a different image. How do I do it ?

推荐答案

您可以使用的方法是 此处描述.由于您的问题没有指定代码更改背景所采取的操作,因此,您可能需要稍微调整引用链接中的代码.请注意,如果您打算按照帖子中建议的路径进行操作,则可能需要从转换器返回 ImageBrush.

An approach you can use is described here. Since your question does not specify the action the code takes to change the background, therefore, you may have to adapt the code in the referred link a bit. Note that you may have to return the ImageBrush from the converter, if you intend to go down the path suggested in the post.

HTH,indyfromoz

HTH, indyfromoz

这篇关于Silverlight/WP7:以编程方式更改按钮背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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