c# - ListBox showing one property in different rows -


i using following code binding listbox list i.e. list , set binding path=name. list box shows 1 name letter divided in rows. if name john, list box row 1 shows "j", row 2 shows "o", row 3 shows "h", row 4 shows "n". here's code.

xaml

<listbox height="auto" itemssource="{binding path=name}" horizontalalignment="stretch" margin="0,80,0,0" name="ledgerlistview" verticalalignment="stretch" width="200" keydown="ledgerlistview_keydown" mousedoubleclick="ledgerlistview_mousedoubleclick" issynchronizedwithcurrentitem="true" /> 

code-behind

list<ledgers> ledgers = new list<ledgers>();         ledgers = dal_ledgers.loadledgers();         this.datacontext = ledgers; 

the itemssource property needs bound source collection want generate list box's items from. in case datacontext. show name each item can either apply datatemplate itemtemplate property containing want show each item, or simple case use displaymemberpath specify name property.

<listbox itemssource="{binding}" displaymemberpath="name" x:name="ledgerlistview"/> 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -