2

こんにちは、mvvmcross プロジェクトでバインドが発生したときにインターセプトする必要があります。

バインドする MvxCollectionViewCell があります。

public ProjectsCollectionCell (IntPtr handle) 
    : base (string.Empty, handle)
{
    this.DelayBind(() => {

        var set = this.CreateBindingSet<ProjectsCollectionCell, ViewItem>();
        set.Bind (lblTitle).To (prj => prj.MnemonicId);
        set.Bind (lblDescription).To (prj => prj.Description);
        set.Bind(imgPhoto).For (s => s.Image).WithConversion("ImageArray").To(prj => prj.Image);
        set.Apply();

        if (imgPhoto.Image != null) {
            this.imgPhoto.Layer.RasterizationScale = UIScreen.MainScreen.Scale;
            this.imgPhoto.Layer.ShouldRasterize = true;
            this.imgPhoto.Layer.BorderWidth = 10;
            this.imgPhoto.Layer.BorderColor = UIColor.White.CGColor;
            this.imgPhoto.Layer.CornerRadius = 8f;
            this.imgPhoto.Layer.MasksToBounds = true;
            this.imgPhoto.Layer.Position = new PointF(imgPhoto.Frame.Left - 80, imgPhoto.Frame.Bottom);
            this.imgPhoto.Transform = CGAffineTransform.MakeRotation(-0.05f);
        };
    });
}

「imgPhoto」の内容が変わったときにインターセプトしたい。

購読するイベントはありますか?

これを行う方法を教えてください。

4

1 に答える 1

1

Imageセルの変更を検出する必要がある場合、DataContextこれを行う 1 つの方法は、セルにプロパティを追加し、そのプロパティをセルにバインドすることですDataContext

  private byte[] _bytes;
  public byte[] Bytes
  {
      get { return _bytes; }
      set
      {
          _bytes = value;
          // your code here...
      }
  }

  public ProjectsCollectionCell (IntPtr handle) 
       : base (string.Empty, handle)
  {

       this.DelayBind(() => {

             var set = this.CreateBindingSet<ProjectsCollectionCell, ViewItem>();
             set.Bind(_hook).For(h => h.CurrentSource);
             set.Bind (lblTitle).To (prj => prj.MnemonicId);
             set.Bind (lblDescription).To (prj => prj.Description);
             set.Bind(this).For(s => s.Bytes).WithConversion("ImageArray").To(prj => prj.Image);
             set.Apply();

             // etc
         });
  }

別の方法として、型が何であれサブクラス化imgPhotoし、そのオブジェクトに新しいプロパティを提供することを検討することもできます。このアプローチの例については、 http://slodge.blogspot.co.uk/2013/07/n33-animating-data-bound-text-changes.htmlAnimatingTextのプロパティを参照してください。

于 2013-07-10T13:10:27.977 に答える