wpf - ComboBox does not reflect its ItemsCount -


i trying build small application combobox , issue items not getting updated in properly, 2 items sometime 4 items getting visible items count getting updated properly. following xaml code:

                <combobox name="numberscombo" width="118">                     <combobox.itemtemplate>                         <datatemplate>                             <textblock text="{binding title}" />                         </datatemplate>                     </combobox.itemtemplate>                 </combobox> 

following code itemssource on page load, con.numbers dictionary of string , numbers class, hence values sent attachment:

numberscombo.itemssource = con.numbers.values 

following code adding new items combobox:

dim temp new bsplib.contactlib.contactcon(con.prime.conid, false) con.numbers.add(temp.conrowid, temp) numberscombo.itemssource = con.numbers.values testlabel1.content = numberscombo.items.count 

following code class:

public class contactcon         property conid string         property conrowid string         property title string         property mob1 string         property mob2 string         property land1 string         property land2 string         property email1 string         property email2 string         property fax1 string         property fax2 string         property primary boolean         public sub new()         end sub          public sub new(byval contactid string, byval primarynumbers boolean)             conid = contactid             conrowid = contactid & "-" & now.tostring             if primarynumbers = true                 title = "primary details"             else                 title = "additional contact numbers"             end if             mob1 = ""             mob2 = ""             land1 = ""             land2 = ""             email1 = ""             email2 = ""             fax1 = ""             fax2 = ""             primary = primarynumbers         end sub     end class      public class contact         public prime contactprime         public addrs dictionary(of string, contactaddress)         public numbers dictionary(of string, contactcon)          public sub new()             numbers = new dictionary(of string, contactcon)              'assigning initial ids , values             dim t new contactcon(prime.conid, vbyes)             numbers.add(t.conrowid, t) 'primary contact number         end sub 

in simple, gui of combo box not showing items items count correct, please tell have gone wrong. thank you.

if want combo box updated automatically when particular contactcon object or collection of contactcon objects changes contactcon class needs implement inotifypropertychanged , need set itemsource collection class implements inotifycollectionchanged (this means have set itemsource once). can find out how implement observable dictionary in answers section of following question.

making these changes fix synchronisation problems seeing.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -