Populating ComboBox inside ListView in WPF -


i have populated combobox inside listview. screen shot given below enter image description here

as shown above it's displaying "m", "a", "c" instead of "mac". why separating word characters?

in code behind file i've written

 itemcategorydal itemcategorydalobj = new itemcategorydal();             datatable datatable = itemcategorydalobj.getallitemcategory();              listview1.itemssource = datatable.defaultview; 

and in .xaml file i've written:

 <listview  height="148" horizontalalignment="left" margin="23,12,0,0" name="listview1" verticalalignment="top" width="447" >   <listview.view>      <gridview>         - - - - - - - -          - - - - - - - -         <gridviewcolumn header="category name" width="150">            <gridviewcolumn.celltemplate>                <datatemplate>                   <combobox itemssource="{binding path=ic_name }" width="120" />                </datatemplate>            </gridviewcolumn.celltemplate>         </gridviewcolumn>          - - - - - - - - -         - - - - - - - - -      </gridview>   </listview.view> </listview> 

i'm using visual studio 2010

screen shot of datatable used itemsource listview.(taken during debuging) enter image description here

a combobox allows user select multiple items. populates iterating through of items in itemssource , adding each item items.

you're setting itemssource property returns string. since string can iterated over, combobox populating items gets when iterating on it, string "mac" turns items "m", "a", , "c".

that's why you're seeing you're seeing. question is: did expect see (or want see) , why? items should combobox displaying? if want display of category names appear in datatable, like:

itemssource="{binding relativesource={relativesource ancestortype=listview}, path=itemssource}" 

and pull out ic_name column each item using datatemplate:

<combobox.itemtemplate>    <datatemplate>       <textblock text="{binding ic_name}"/>    </datatemplate> </combobox.itemtemplate> 

note there going kinds of unexpected phenomena encounter doing this. instance, if 1 row in table has "foo" value of ic_name, moment user selects other value row , table gets updated, value "foo" disappear of comboboxes, making impossible user undo change. also, if 5 rows contain "foo", each combobox display 5 instances of "foo" in dropdown.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -