c# - Combobox SelectedItem and Binding in UWP -


currently developing uwp application having troubles comboboxes.

i binding observablecollection combobox (it works)

var warehouselist = new observablecollection<warehouse>(taskmag.result);         warehousebox.itemssource = warehouselist; 

what show selecteditem when load data form. not using mvvm , combox xaml

<combobox horizontalalignment="stretch" width="400" fontsize="32" name="warehousebox" margin="20,0,0,0">  <combobox.itemtemplate>   <datatemplate>    <stackpanel orientation="horizontal" width="auto" height="auto">     <textblock text="{binding name}"/>     <textblock text="{binding warehouseid}" name="mid" visibility="collapsed"/>    </stackpanel>   </datatemplate>  </combobox.itemtemplate> </combobox> 

i have no idea start documentation implies mvvm or other thing have not implemented. willing change items coll list or ienumerable if can solve issue.

any appreciated.

here's full thing, let me know if still doesn't work you:

<grid background="{themeresource applicationpagebackgroundthemebrush}">         <combobox x:name="comboboxwarehouses">             <combobox.itemtemplate>                 <datatemplate>                     <stackpanel orientation="horizontal" width="auto" height="auto">                         <textblock text="{binding name}"/>                     </stackpanel>                 </datatemplate>             </combobox.itemtemplate>         </combobox>     </grid>      public mainpage()     {         this.initializecomponent();         var items = new observablecollection<warehouse>();         var item = new warehouse() {name = "selected"};         items.add(new warehouse() { name = "not selected"});         items.add(item);         items.add(new warehouse() { name = "another not selected"});          comboboxwarehouses.itemssource = items;         comboboxwarehouses.selecteditem = item;     } 

page


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -