[英]Grid Background ImageSource binding breaks app return from background Windows Phone 8
我正在按照Microsoft的本指南加载与分辨率相关的图像作为我的应用程序的背景。
例如在我的关于页面中,我有以下代码
<Grid>
<Grid.Background>
<ImageBrush ImageSource="{Binding BestResolutionImage, Source={StaticResource MultiResImageChooser}}"/>
</Grid.Background>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Margin="12,0,12,0">
<phone:Pivot Title="ABOUT" x:Name="helPagePiv">
<!--Pivot item one-->
<phone:PivotItem Header="about us">
<controls:About />
</phone:PivotItem>
<!--Pivot item two-->
<phone:PivotItem Header="change log">
<controls:ChangeLog />
</phone:PivotItem>
</phone:Pivot>
</Grid>
</Grid>
它可以正常工作,但是当我单击启动电子邮件应用程序的链接或将我的应用程序置于后台的浏览器控件时,会出现问题。 当我使用后退硬件按钮返回到我的应用程序时,不会重新加载背景图像,导致背景为空。
我想我必须在某个地方使用INotifyPropertyChanged
。 无论如何,当我返回应用程序时,如何确保刷新了背景图片?
更新我曾尝试更改绑定Mode
但这并没有什么不同。
更新2 Windows Phone 8.1中似乎似乎没有此问题。 因此,如果我现在更新到8.1,现在很好。
您将必须在MultiResImageChooser类中实现INotifyPropertyChanged。 您将必须在此类属性的设置器中引发BestResolutionImage属性的属性更改事件。
public class MultiResImageChooser : INotifyPropertyChanged
{
public event NotifyPropertyChangedArgs PropertyChanged;
...
public ImageSource BestResolutionImage
{
get
{
return _bestResolutionImage;
}
set
{
if(value != _bestResolutionImage)
{
_bestResolutionImage = value;
OnPropertyChanged("BestResolutionImage");
}
}
}
protected virtual void OnPropertyChanged(string property)
{
if(null != PropertyChanged)
{
PropertyChanged(this, new NotifyPropertyChangedEventArgs(property));
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.