c# - WPF - ItemControl DataBinding in a WrapPanel/Grid -


i read out images own datatype , sync list grid/wrappanel via itemcontrol binding.

my xaml:

    <wrappanel >     <itemscontrol name="images">         <itemscontrol.itemtemplate>             <datatemplate>                  <image source="{binding link}" stretch="none"  ></image>               </datatemplate>         </itemscontrol.itemtemplate>     </itemscontrol> </wrappanel> 

c# code:

 public mainwindow()     {         initializecomponent();         list<movie> items = new list<movie>();         items.add(new movie() { name = "movie1", link = "http://www.airvana.com/default/cache/file/1601d22d-9266-de31-d6b8d178db2933dc_small.png", column =0 });        items.add(new movie() { name = "movie2", link = "http://www.airvana.com/default/cache/file/1601d22d-9266-de31-d6b8d178db2933dc_small.png"});       items.add(new movie() { name = "movie2", link = "http://www.airvana.com/default/cache/file/1601d22d-9266-de31-d6b8d178db2933dc_small.png"});        // items.add(new movie() { name = "movie3"});          images.itemssource = items;     } } public class movie {     public string name { get; set; }     public string link { get; set; } } 

this works well, problem have (and why tried wrappanel instead of grid) 3 images below each other, not next each other.

how looks

if without binding , using wrappanel , adding 3 images, works perfectly.

basically i'd set of images, picture collage - there better way so?

itemspaneltemplate defines panel use layout of items. the default value itemscontrol itemspaneltemplate specifies stackpanel.

wraping bunch of vertically stacked images in wrappanel not going make them horizontal. need change layout :

<itemscontrol name="images" >     <itemscontrol.itemtemplate>         <datatemplate>             <image source="{binding link}" stretch="none" ></image>         </datatemplate>     </itemscontrol.itemtemplate>     <itemscontrol.itemspanel>         <itemspaneltemplate>             <wrappanel />         </itemspaneltemplate>     </itemscontrol.itemspanel> </itemscontrol> 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -