【发布时间】:2014-09-02 11:08:45
【问题描述】:
当用户在其设置中更改手机主题时,我正在尝试更改 ImageBrush 的 ImageSource。
所以目前我有这个:
XAML:
<ImageBrush ImageSource="{Binding ImageSource, Mode=OneTime}" Stretch="UniformToFill"/>
代码隐藏:
public string ImageSource
{
get
{
if ((Visibility)App.Current.Resources["PhoneDarkThemeVisibility"]
== Visibility.Visible)
{
return "/Images/BGDark.png";
}
else
{
return "/Images/BG.png";
}
}
private set { }
}
如您所见,我在应用程序启动时设置背景。该应用程序将通过查看已选择的主题来设置背景。
我现在的问题是,当用户进入设置(应用程序尚未关闭!)并更改主题时,当他再次激活应用程序页面时,背景/图像源将不会更新。 我想也许我可以通过在这里设置新的背景来改变它:
App.xaml.cs:
private void Application_Activated(object sender, ActivatedEventArgs e)
{
//access somehow the CodeBehind of my MainPage and change the ImageSource
}
但我不知道如何访问该属性... 是否有其他解决方案可以在应用仍在运行且用户更改主题时更改背景?
【问题讨论】:
标签: c# xaml binding windows-phone