【发布时间】:2016-07-15 09:35:31
【问题描述】:
我需要在View 上刷新Image
这是我的 ViewPage:
<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 没有显示。我有什么问题?
【问题讨论】:
-
ApplyEffectAsync在哪里调用? -
它在另一个类中用
ICommand调用,并且此方法可以正常工作。下一个 VS 转到我的二传手并调用RaisePropertyChanged但视图上没有显示任何内容 -
我贴出来了。我用
Source="{Binding Orig}" -
好吧,我们很清楚,我一直在 UWP 中使用 INotifyPropertyChanged。它工作大声笑...其次,你的输出窗口说什么?是否有任何 BindingExpression 错误?图片的实际来源路径是什么?
-
我没有任何错误或异常。我使用
FilePicker打开我的图像,然后将其放入StorageFile并使用FileStream放入WriteableBitmap
标签: c# windows visual-studio xaml uwp