How to replace code-based Pivot Application background?

I use my own 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 runtime. Is it possible?

+3
source share
1 answer

You can specify a ImageBrushname:

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

Then change the source code in the code:

BitmapImage bi = new BitmapImage(new Uri("mySecondImage.png", UriKind.Relative));
ibPivot.ImageSource = bi;
+7
source

All Articles