c# - Images disappear in SliderView and ListView while scrolling -


i have sliderview (of appstudio.uwp.controls). images appear load page disappear when scroll through list. tested listview too. same thing happening there too.

        <controls:sliderview x:name="sliderview" itemssource="{x:bind listforotherpicturesthumbnails}" itemtemplate="{staticresource hero}"                      relativepanel.below="mainimage"                      relativepanel.alignleftwithpanel="true"                      relativepanel.alignrightwithpanel="true"                      arrowsvisibility="visible"                      /> 

the itemtemplate used follows-

    <datatemplate x:key="hero" x:datatype="local:storageitemthumbnailclass">         <grid margin="6" padding="12" background="white" borderthickness="1" borderbrush="lightgray">             <image source="{x:bind thumbnail, converter={staticresource thumbnailtoimageconverter}}" stretch="uniformtofill" horizontalalignment="center" verticalalignment="center" />         </grid>     </datatemplate> 

thumbnails produced follows in onnavigated function-

    protected async override void onnavigatedto(navigationeventargs e)     {         otherpicturespathlist = ((picturewithlist)e.parameter).pathlist;          await populatelistofotherpicturesthumbnailsasync();          bindings.update();     }      private async task populatelistofotherpicturesthumbnailsasync()     {         if (otherpicturespathlist != null)         {             list<task<storageitemthumbnail>> thumbnailoperations = new list<task<storageitemthumbnail>>();              foreach (var path in otherpicturespathlist)             {                 var storagefile = await storagefile.getfilefrompathasync(path);                 thumbnailoperations.add(storagefile.getthumbnailasync(windows.storage.fileproperties.thumbnailmode.picturesview, 100).astask());             }              await task.whenall(thumbnailoperations);              (int k = 0; k < thumbnailoperations.count; k++)             {                 var task = thumbnailoperations[k];                 listforotherpicturesthumbnails.add(new storageitemthumbnailclass { thumbnail = task.result });             }         }     } 

thumbnail image converter-

 public object convert(object value, type targettype, object parameter, string language)     {         bitmapimage image = null;         if (value != null)         {             if (value.gettype() != typeof(storageitemthumbnail))             {                 throw new argumentexception("expected thumbnail");             }             storageitemthumbnail thumbnail = (storageitemthumbnail)value;             image = new bitmapimage();             image.setsource(thumbnail);         }         return (image);     } 

storageitemthumbnailclass-

public class storageitemthumbnailclass : inotifypropertychanged {     public event propertychangedeventhandler propertychanged;     private storageitemthumbnail _thumbnail;     private string _name;      public storageitemthumbnail thumbnail     {         { return _thumbnail; }         set         {             _thumbnail = value;             // call onpropertychanged whenever property updated             onpropertychanged("thumbnail");         }     }      // create onpropertychanged method raise event     protected void onpropertychanged(string name)     {         propertychanged?.invoke(this, new propertychangedeventargs(name));     }      public string name     {         { return _name; }         set         {             _name = value;             // call onpropertychanged whenever property updated             onpropertychanged("name");         }     }  } 

how fix issue images remain seen when page first loaded?

i stumbled on same problem.
solution add thumbnail.seek(0); in thumbnailtoimageconverter.

//... storageitemthumbnail thumbnail = (storageitemthumbnail)value; thumbnail.seek(0); image = new bitmapimage(); image.setsource(thumbnail); 

reflink: images disappear in sliderview , listview while scrolling


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

http - Safari render HTML as received -