【问题标题】:Databinding Image Source at Windows PhoneWindows Phone 上的数据绑定图像源
【发布时间】: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


    【解决方案1】:

    问题在于创建绑定:我忘了Mode=TwoWay

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-29
      • 2013-09-23
      • 1970-01-01
      • 1970-01-01
      • 2014-03-30
      相关资源
      最近更新 更多