如何从代码背后替换Pivot应用程序背景



我在Pivot(而不是Panorama)应用程序中使用自定义背景图像:

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

它工作正常,但我想在运行时替换图像。有可能吗?

您可以为ImageBrush命名:

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

然后更改后面代码中的源代码:

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

最新更新