【发布时间】:2023-03-18 07:12:01
【问题描述】:
我有带有 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 更新时触发它?
【问题讨论】:
标签: c# data-binding windows-phone