Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Binding ImageCell.ImageSourceProperty and ImageSource.FromUri

$
0
0

I'm trying to fill a ListView with images from a web server. (contact list like) but I can't achieve nothing, images doesn't appear thou they are 84x60 and the ListView.RowHeight is set. the listView only displays the contact name.

I'm using PCL and i tested on Android Lollipop using an Android Player.

The same images are shown if loaded like any other image from the proyect Source = "myimage.png" (also 84x60), connection to internet its ok with the Player.

Here is what i'm doing (long story short version):

    public class ProfileItem
    {
            public UriImageSource ImageSource { get; set; }

            public string DisplayName { get; set; }
    }

The FriendList() data:

    Public List<ProfileItem>FriendList()
    {
            //[...]   //data connections and magic stuff
            foreach (var profile in friendProfiles)
            {
                    ProfileItem pItem = new ProfileItem();
                    pItem.DisplayName = profile.DisplayName;
                    var imagen = new UriImageSource()
                        {
                            CachingEnabled = false;
                            Uri = new Uri("http://myserver/imagefolder/image.jpg"),
                        };
                    pItem.ImageSource = imagen;
                    amigos.Add(pItem)
            }
        return(amigos);
    }

The listView

public class FriendListView : ListView
{
    public FriendListView()
    {
        List<ProfileItem> friendList = new FriendList();
        RowHeight = 70;
        this.ItemTemplate = new DataTemplate(typeof(ImageCell)); 
        this.ItemTemplate.SetBinding(TextCell.TextProperty, "DisplayName");
        this.ItemTemplate.SetBinding(ImageCell.ImageSourceProperty, "ImageSource");
        VerticalOptions = LayoutOptions.FillAndExpand;
    }
}

Any ideas on what's going on?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>