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开发者_如何学Python" Stretch="Fill"/>
</controls:Pivot.Background>
It works fine, but I would like to replace the image at run-time. Is it possible?
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;
精彩评论