User Profile & Activity

Leo Hong Member
Page
of 3

I tried your sample code. It's ok for TextProperty or ImageSourceProperty, but CommandProperty of UIButton still does not work. No matter using AddBinding or AddViewModelBinding.

itemBinding.AddBinding("OKLabel", BindableProperties.TextProperty, "Title", TargetBindingType.Group);
itemBinding.AddBinding("OKButton", BindableProperties.TextProperty, "Title", TargetBindingType.Group);
itemBinding.AddViewModelBinding("OKButton", BindableProperties.CommandProperty, "OKCommand", TargetBindingType.Group);
itemBinding.AddBinding("OKButton", BindableProperties.CommandParameterProperty, ".", TargetBindingType.Group);

My internet connection is also fast, about 20Mb/s, my server bandwidth is 1Mb/s.

I think this issue happens when the first response data is loaded but the UI is still calculating, and then the second request sends out immediately, when the second response data is also loaded into memory, the UI tries to reload UITableView and cannot decide current scroll position.

Just my imagination.

This issue should happen when swipe the UI so fast, or the layout of the UITableViewCell is too complicated to perform WillDisplay and GetHeight.

Please take a look at my sample. WebAPI is hosting on my web server.

Too many requests when incremental loading.

WebAPI.zip

Hi Arief,

I know the UIImageView can bind to ImageSourceProperty with string by using this.AddBinding method. The issue I pointed out only happens in the item binding and only in the UITableView.

itemBinding.AddBinding("ImageView", BindableProperties.ImageSourceProperty, "ThumbnailImageUrl");
this.AddBinding("TableView", BindableProperties.ItemsSourceProperty, "Items");

Please take a look.

My TableViewCell may be like this:

  public partial class CommentReplyCell : UITableViewCell, ISupportDynamicHeight

    {        public static readonly UINib Nib = UINib.FromName("CommentReplyCell", NSBundle.MainBundle);
        public static readonly NSString Key = new NSString("CommentReplyCell");

...
...

        #region ISupportDynamicHeight Members

        public void WillDisplay(ITableViewController viewController, object item)
        {
            AppSimpleUserReply userReply = item as AppSimpleUserReply;
            if (userReply != null)
            {
                if (userReply.IsBanned)
                {
                    TitleLabel.Frame = new CGRect(ReplierImageView.Frame.Right + 4, BanIconView.Frame.Bottom + 6, Bounds.Width - ReplierImageView.Frame.Right - 8, 1);
                }
                else
                {
                    TitleLabel.Frame = new CGRect(ReplierImageView.Frame.Right + 4, CreatedDateLabel.Frame.Bottom + 6, Bounds.Width - ReplierImageView.Frame.Right - 8, 1);
                }
                TitleLabel.SizeToFit();

                // Attachment Position
                switch (userReply.AttachmentType)
                {
                    case 0:
                        break;
                    case 1:
                        AttachmentImageView.Frame = new CGRect(ReplierImageView.Frame.Right + 4, TitleLabel.Frame.Bottom + 4, 96, 96);
                        break;
                    case 2:
                        break;
                    case 3:
                        break;
                }
            }
        }

        public float GetHeight(ITableViewController viewController, object item)
        {
            AppSimpleUserReply userReply = item as AppSimpleUserReply;
            if (userReply != null)
            {
                var leftHeight = ReplierImageView.Frame.Bottom + 8;
                var rightHeight = CreatedDateLabel.Frame.Bottom;
                if (userReply.IsBanned)
                {
                    rightHeight += 4;
                    rightHeight += BanIconView.Bounds.Height;
                    rightHeight += 6;
                }
                else
                {
                    rightHeight += 6;
                }
                rightHeight += TitleLabel.SizeThatFits(new CGSize(TitleLabel.PreferredMaxLayoutWidth, 1)).Height;

                // Attachment position
                switch (userReply.AttachmentType)
                {
                    case 0:
                        break;
                    case 1:
                        rightHeight += 4;
                        rightHeight += AttachmentImageView.Bounds.Height;
                        break;
                    case 2:
                        break;
                    case 3:
                        break;
                }
                rightHeight += 8;
                return (float) Math.Max(leftHeight, rightHeight);
            }
            return 0;
        }

        #endregion
}

Is there any problems? I tested code on my iPhone, the cell layout and height is OK. The only issue is data incremental loading.

Please add support of BindableProperties.ImageSourceProperty.

For now, when I bind an UIImageView to ImageSourceProperty, The "Object reference null" exception will be thrown.

I checked UICollectionViewBindingAdapter, I found it does not support RefreshCommandProperty.

Please add this feature

The CustomStyleListViewController uses CustomListBindingProvider , this provider uses ImageMemberPath and BindableProperties.ImageProperty, it works fine. But sometimes there are multiple UIImageViews in one cell, ImageMemberPath can only be binded to one UIImageView, and BindableProperties.ImageProperty should be binded to byte[] which need to be preloaded by using ImageLoadService manually.

BindableProperties.ImageSourceProperty is a good solution, it supports in UICollectionView, but it seems cannot be used in UITableView. You can change the CustomListBindingProvider a little bit (where ThumbnailImageUrl is a string property in Item entity and stands for a remote image url):

using System;using Intersoft.Crosslight;

namespace DataSamples
{
    public class CustomListBindingProvider : BindingProvider
    {
        public CustomListBindingProvider()
        {
            ItemBindingDescription itemBinding = new ItemBindingDescription()
            {
                DisplayMemberPath = "Name",
                DetailMemberPath = "Location",
            };

            itemBinding.AddBinding("TextLabel", BindableProperties.TextProperty, "Name");
            itemBinding.AddBinding("DetailTextLabel", BindableProperties.TextProperty, "Location");
            itemBinding.AddBinding("ImageView", BindableProperties.ImageSourceProperty, "ThumbnailImageUrl");
            itemBinding.AddBinding("PriceLabel", BindableProperties.TextProperty, new BindingDescription("Price") { StringFormat = "{0:c}" });

            this.AddBinding("TableView", BindableProperties.ItemsSourceProperty, "Items");
            this.AddBinding("TableView", BindableProperties.ItemTemplateBindingProperty, itemBinding, true);
        }
    }
}
All times are GMT -5. The time now is 2:02 AM.
Previous Next