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?