c# - 如何从代码隐藏中替换 Pivot 应用程序背景?

标签 c# silverlight xaml windows-phone-7

我在 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;

关于c# - 如何从代码隐藏中替换 Pivot 应用程序背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6397026/

相关文章:

c# - 静态成员未初始化 - 从数组元素中获取 System.NullReferenceException

时间:2019-05-17 标签:c#winform: node expand and collapse in TreeView

ios - iPad 上的 Silverlight 支持吗?

c# - 使用 XAML 绑定(bind)设置具有自定义标签的 LiveCharts 系列的颜色

c# - 使用语句不能正常工作

c# - 是否可以只在 ASP.Net 中处理 404 错误?

silverlight/windows phone 7 selectedIndex 列表框中按钮的问题

silverlight - 如何更改 Silverlight 中文本 block 的背景颜色?

wpf - 如何将多个 XAML 样式应用于一个元素?

c# - 仅在 Windows 应用商店应用程序中保存 Canvas 的剪切区域