Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Grid Background ImageSource绑定中断应用程序从后台Windows Phone 8返回_C#_Windows Phone 8_Binding_Background_Imagesource - Fatal编程技术网

C# Grid Background ImageSource绑定中断应用程序从后台Windows Phone 8返回

C# Grid Background ImageSource绑定中断应用程序从后台Windows Phone 8返回,c#,windows-phone-8,binding,background,imagesource,C#,Windows Phone 8,Binding,Background,Imagesource,我正在跟踪以加载分辨率相关的图像作为我的应用程序的背景 例如,在我的“关于”页面中,我有以下代码 <Grid> <Grid.Background> <ImageBrush ImageSource="{Binding BestResolutionImage, Source={StaticResource MultiResImageChooser}}"/> </Grid.Background> <!--Co

我正在跟踪以加载分辨率相关的图像作为我的应用程序的背景

例如,在我的“关于”页面中,我有以下代码

<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>
它工作正常,但当我单击启动电子邮件应用程序的链接或将我的应用程序置于后台的浏览器控件时,就会出现问题。当我使用back hardware(返回硬件)按钮返回应用程序时,不会重新加载背景图像,导致背景为空

我想我必须在某个地方使用InotifyProperty更改。无论如何,我如何确保在返回到我的应用程序时刷新背景图像

更新 我尝试过改变绑定模式,但没有任何不同

更新2
Windows Phone 8.1中似乎没有此问题。因此,如果我现在更新到8.1,那就很好了。

您必须在MultiResImageChooser类中实现INotifyPropertyChanged。 您必须在此类属性的setter中引发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));
        }
    }
}

谢谢在哪里引发属性更改事件?在页面构造函数中?要提高分辨率,我必须将BestResolutionImage设置为正确的值?但它取决于屏幕分辨率,并且该值不会保存在_bestResolutionImage中。