2016-07-15 39 views
1

你好,我需要刷新ImageView 這是我的ViewPage:INotifyPropertyChanged的不工作(UWP

<Image Grid.Row="1" 
Grid.Column="1" 
x:Name="OriginalImg" 
Source="{Binding Orig}" 
DataContext="{StaticResource MainViewModel}"/> 

進出口使用MVVMLibs包,這是我的ViewModel:

public class MainViewModel: ViewModelBase 
{ 

    private WriteableBitmap original = new WriteableBitmap(1280,720); 
    private WriteableBitmap temp = new WriteableBitmap(1280,720); 

    public WriteableBitmap Orig 
    { 
     get { return original; } 
     set 
     { 
      this.original = value; 
      base.RaisePropertyChanged("Orig"); 
     } 
    } 
    public async Task<bool> ApplyEffectAsync(StorageFile file) 
    { 
     fileStream = await file.OpenAsync(FileAccessMode.Read); 
     temp.SetSource(fileStream); 
     Orig = temp; 
    } 
} 

Image我頁面不顯示。什麼是我的問題?

+0

「ApplyEffectAsync」在哪裏調用? – niksofteng

+0

它在另一個類中用'ICommand'調用,並且此方法正常工作。然後下一個VS去我的二傳手,並調用'RaisePropertyChanged',但沒有任何顯示在我看到 – SmiLe

+0

張貼它。我使用'Source =「{Binding Orig}」' – SmiLe

回答

0

問題是你沒有真正實例化一個新的WriteableBitmap,只是改變它的來源。所以雖然它可能是第一次,但它肯定不會工作,因爲依賴屬性管理器不會知道你的圖像改變,除非它的instace改變。

嘗試在ApplyEffectAsync方法中創建臨時WriteableBitmap。

相關問題