Windows Phone 中的数据绑定图像源

本文关键字:图像 数据绑定 Phone Windows | 更新日期: 2023-09-27 18:30:24

>我有带有byte[]列的数据表。在应用程序页面上,我循环访问行并将列数据绑定到源属性

for (i = 0;..) {
    Image img = new Image();
    img.Width = 100;
    img.Height = 100;
    Binding bnd = new Binding("Fields[" + i + "].Blob"); // Blob column
    bnd.Converter = new ByteToImageConverter();
    img.SetBinding(Image.SourceProperty, bnd);
}

在每张图像附近,我都有调用CameraCaptureTask camTask的按钮。

camtask.Show()之前,我将当前图像分配给全局指针_imgCurrent = img

camtask.Completed += (s, e)
{
    if (e.TaskResult != TaskResult.OK) return;
    BitmapImage bmp = new BitmapImage();
    bmp.SetSource(e.ChosenPhoto);
    _imgCurrent.Source = bmp;
    _imgCurrent.SetValue(Image.SourceProperty, bmp);
}

但在这种情况下,DataContext 不会更新。我想我需要实现INotifyPropertyChanged?我需要从该接口继承图像,或者我可以在源更新时触发它?

Windows Phone 中的数据绑定图像源

问题出在绑定创建上:我忘记了Mode=TwoWay