iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
In iOS development, I found when use custom UITableViewCell, it seems that UIImageView in the cell does not support binding to the ImageSourceProperty, It is OK when used in UICollectionView.
Please take a look.
Hi Leo,I can bind my image source property from custom UiTableViewCell with the binding provider, is the binding provider and .xib connection that you mean? I am using newest DataSamples from here for UITableViewCell inside CustomStyleListViewController.cs & CustomTableCell.xibCould you please send me a samples for UITableViewCell problem?Best Regards,Arief
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); } } }
ItemBindingDescription itemBinding = new ItemBindingDescription(){ DisplayMemberPath = "Name", DetailMemberPath = "Location", ImageMemberPath = "ThumbnailImage" };
MemberPath is only mandatory for non-custom table cell, so you can remove member path and can easily bind more than one image view for example in our case (CustomListBindingProvider) into like this:
ItemBindingDescription itemBinding = new ItemBindingDescription(); itemBinding.AddBinding("ImageView", BindableProperties.ImageProperty, "ThumbnailImage"); itemBinding.AddBinding("ImageView2", BindableProperties.ImageProperty, "YourOtherImage");
Yes we recommend you use ImageLoadService, as far as i already try looks like i can't manually bind byte[] to imageProperty without loading the imageLoader Service
Yeah imageProperty only for byte[]
Please add support of BindableProperties.ImageSourceProperty.
For now, when I bind an UIImageView to ImageSourceProperty, The "Object reference null" exception will be thrown.
Hi Leo,In IOS ImageSourceProperty can only accept string, yet ImageProperty can only accept byte[]you get that error if bind imageSourceProperty with Byte[], here i have example of using ImageSourceProperty in IOS (need internet to load the picture) (to run dont forget to add crosslight assemblies in packages folder and download Microsoft Async from package manager)For android, it's image view accept both byte[] and string
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");
Hi Leo,I finally found the problem, actually our Crosslight is always reserve first UIimageView (in table type view) to
ItemBindingDescription itemBinding = new ItemBindingDescription(){ImageMemberPath = "ImageURL"};
The reason are it should be better practice to use the member path, i correct my statement sorry, however in case you have more than one image view you can use
itemBinding.AddBinding("ImageView2", BindableProperties.ImageSourceProperty, "ImageURL");
ImageView name are reserved for imageMemberPathSo, in case you have more than one image view, it is better to have imageMemberPath for the first UIImageVIew then for the later user itemBinding, also "ImageView" name are reserved for imageMemberPath so for other image view please use different name.One more thing i was actually add the URL data inside database & Model not manually from ViewModel, if you add data manually the url will fail to loadI attach my sample (need xamarin, intersoft, microsoft async assemblies)
Is there any updates?
I added 2 UIImageView in the ItemListViewCell which named ItemImageView and TestImageView. When I bind ImageSourceProperty to each of them with different image source url, The "Object reference not set to an instance of an object" exception is thrown.
The binding info is shown as below. It is in the ItemListBindingProvider.cs file.
ItemBindingDescription itemBinding = new ItemBindingDescription { //DisplayMemberPath = "Name", //DetailMemberPath = "Location", //ImageMemberPath = "ResolvedThumbnailImage", //ImagePlaceholder = "item_placeholder.png" }; itemBinding.AddBinding("ItemImageView", BindableProperties.ImageSourceProperty, "ResolvedThumbnailImage"); itemBinding.AddBinding("TestImageView", BindableProperties.ImageSourceProperty, "ResolvedTestImage"); itemBinding.AddBinding("TestImageView", BindableProperties.IsVisibleProperty, "Sold");
By the way, it is no problem when use this bind info on Android platform. Please take a look.
I uploaded my sample: MyInventory.7z
Any updates?
Hi Leo,Sorry for the late response, in IOS you actually MUST bind the first ImageView using member path like this:
ItemBindingDescription itemBinding = new ItemBindingDescription { //DisplayMemberPath = "Name", //DetailMemberPath = "Location", ImageMemberPath = "ResolvedThumbnailImage", //ImagePlaceholder = "item_placeholder.png" }; itemBinding.AddBinding("ItemImageView", BindableProperties.ImageSourceProperty, "ResolvedThumbnailImage"); itemBinding.AddBinding("TestImageView", BindableProperties.ImageSourceProperty, "ResolvedTestImage"); itemBinding.AddBinding("TestImageView", BindableProperties.IsVisibleProperty, "Sold");
The problem is when use ImageMemberPath, the two image views will show the same picture. Please take a look at my attachment images.
My requirement is the two image views should show different images, that's why I need to use ImageSourceProperty. It's no problem on Android platform.
Hi Leo, Even though i already use the newest crosslight assemblies looks like the error is still there, i already report your issue to our programmer (duplication & error ones) with code CROS-796 and CROS 797, i will update you with new information about the fix.Meanwhile i'm suggesting using only byte[] image data (ImageProperty) using ImageProperty i encounter no error (use ImageMemberPath or not) hope that helpsBest RegardsArief
Hi Leo,
We have uploaded the hotfix for CROS-796 & CROS-797 (Duplication and also improvement for supporting multiple image view in custom table cell). You can download the nightly build here. Please note that you need to use Unified API for it to work.
Best Regards,Arief
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname