c# - Databinding a List inside of a data bound class to a Listview -


still learning databinding.. , thought got down i'm having trouble binding list inside class that's databinded.. if makes sense

displaymemberbinding="{binding _engine} 

i part of code under gridviewcolumn display whole list of engines have in list... ideally i'd maybe overwrite tostring() or have display like.. every engine in list display "_name" property.. have no idea how this? tried adding method engine class can't seem access through wpf.. kinda clueless here, appreciate help.

edit clarification of want do:

as of listview has 2 columns.. "name" , "active engines".. "name" column fine.. under "active engines".. since listview databound playlistcollection of playlist object...i display listed under playlist-->_engine-->_name. since _engine list.. display "_name" properties in list. let me know if doesn't make sense still

<window name="this" ....>  <listview x:name="playlists_listview" itemssource="{binding playlistcollection, elementname=this}" background="#ffc9c9c9" margin="0,5,0,0" visibility="visible" scrollviewer.horizontalscrollbarvisibility="disabled" fontsize="12">     <listview.view>         <gridview>             <gridviewcolumn header="name" displaymemberbinding="{binding _name}" width="150"/>             <gridviewcolumn header="active engines" displaymemberbinding="{binding _engine}" width="240"/>         </gridview>     </listview.view> </listview>  public static observablecollection<playlist> _playlistcollection = new observablecollection<playlist>();  public static observablecollection<playlist> playlistcollection {     { return _playlistcollection; } }      public class playlist {     public string _name { get; set; }     public list<engine> _engine { get; set; }              public playlist(string name, list<engine> engine)     {         _name = name;         _engine = engine;     }         }  public class engine {     public string _name { get; set; }     public string _ip { get; set; }     public bool _active { get; set; } } 

if want display _name of _engine in 1 column can set celltemplate itemscontrol. should work:

<gridviewcolumn header="active engines">    <gridviewcolumn.celltemplate>       <datatemplate>          <itemscontrol itemssource="{binding _engine}" displaymemberpath="_name">             <itemscontrol.itemspanel>                <itemspaneltemplate>                   <stackpanel orientation="horizontal"/>                </itemspaneltemplate>             </itemscontrol.itemspanel>          </itemscontrol>       </datatemplate>    </gridviewcolumn.celltemplate> </gridviewcolumn> 

edit

to display items stacked horizontally need set itemspanel horizontal stackpanel


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -