0
我有以下类PhotoChooserTask结果:数据绑定Image.Source不工作
public class Sticky : INotifyPropertyChanged {
// ... some members
private BitmapImage _frontPic;
[DataMember]
public BitmapImage FrontPic {
get {
return _frontPic;
}
set {
_frontPic = value;
Changed("FrontPic");
Changed("FrontBrush");
}
}
}
我试图把它的数据绑定到这个XAML:推出PhotoChooserTask这个后
<Image Width="173" Height="173" Source="{Binding FrontPic}" />
代码在我的PhoneApplicationPage:
public Sticky Sticky { get; set; }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) {
Sticky = new Sticky();
DataContext = Sticky;
}
private void ShowFrontPicPicker(object sender, RoutedEventArgs e) {
var t = new PhotoChooserTask();
t.PixelHeight = 173;
t.PixelWidth = 173;
t.ShowCamera = true;
t.Completed += (s, ev) => {
if (ev.TaskResult == TaskResult.OK) {
var img = new BitmapImage();
img.SetSource(ev.ChosenPhoto);
Sticky.FrontPic = img;
}
};
t.Show();
}
但是,我的图像仍然是空白。如果我将Image.Source属性直接分配给没有数据绑定的Image,则一切正常。数据绑定其他属性的作品,这只是图像,似乎是问题。我怎样才能使图像工作DataBinding?