<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 中,我必须以编程方式将图像源更改为不同的图像。我该怎么做 ?
最佳答案
使用
searchImage.ImageSource =
new BitmapImage(new Uri(imgPath, UriKind.Relative));
更改与背景图像刷关联的图像。
关于银光/WP7 : programmatically change the button background image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3797304/