Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight/WP7: programmatically change the button background image

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

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

like image 749
gforg Avatar asked Apr 21 '26 20:04

gforg


1 Answers

Use

searchImage.ImageSource =

        new BitmapImage(new Uri(imgPath, UriKind.Relative));

to change the image associated with background image brush.

like image 194
Vinay B R Avatar answered Apr 30 '26 16:04

Vinay B R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!