Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace Pivot Application background from code-behind?

I'm using custom background image in Pivot (not Panorama) Application:

<controls:Pivot Title="My Application">
<controls:Pivot.Background>
    <ImageBrush ImageSource="Theme1.png" Stretch="Fill"/>
</controls:Pivot.Background>

It works fine, but I would like to replace the image at run-time. Is it possible?


1 Answers

You can give your ImageBrush a name:

<ImageBrush x:Name="ibPivot" ImageSource="Theme1.png" Stretch="Fill"/>

Then change the source in the code-behind:

BitmapImage bi = new BitmapImage(new Uri("mySecondImage.png", UriKind.Relative));
ibPivot.ImageSource = bi;
like image 65
keyboardP Avatar answered Jun 03 '26 02:06

keyboardP