0

我有带有 byte[] 列的数据表。在应用程序页面上,我遍历行并将列数据绑定到 SourceProperty

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?我需要从该接口继承 Image 还是可以在 Source 更新时触发它?

4

1 回答 1

0

问题在于 Binding 创建:我忘记了Mode=TwoWay.

于 2013-09-10T07:29:31.690 回答