簡體   English   中英

網格背景ImageSource綁定中斷了從后台Windows Phone 8返回的應用程序

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM