如何从代码背后替换Pivot应用程序背景
本文关键字:Pivot 应用程序 背景 替换 背后 代码 | 更新日期: 2023-09-27 17:59:24
我在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;