简体   繁体   中英

Databinding Image Source at Windows Phone

I have datatable with byte[] column. On app page I iterate through rows and bind column data to 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);
}

Near every image I have button that calls CameraCaptureTask camTask .

Before camtask.Show() I assign current Image to global pointer _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);
}

But in that case DataContext don't update. I suppose that I need to implement INotifyPropertyChanged ? I need to inherit Image from that interface or I can trigger it in time of Source update?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM