WPF/C# Combobox Only Changes Selection When A Click is Detected Outside of Text Area -


so have several comboboxes in wpf application don't change selection when user clicks on text of combobox item. in order select particular item have click right or left of text. have combobox selects fine when text clicked. difference between 2 databinding. comboboxes don't select when text clicked databound observablecollection of 1 type or another. combobox works has manually inserted, static values.

i've searched issue extensively , can't seem find else has had issue or remotely similar. i'm not setting weird properties.

here code 1 of problematic comboboxes:

<combobox horizontalalignment="left" margin="40,160,0,0" verticalalignment="top" width="132" itemssource="{binding path=systems}" selecteditem="{binding path=system}" selectedindex="0">      <combobox.itemtemplate>          <datatemplate>              <comboboxitem content="{binding path=name}"/>          </datatemplate>      </combobox.itemtemplate>  </combobox> 

here video of behavior:

http://www.youtube.com/watch?v=d0r1n1ghw-k

enter code heresuppose combobox defind below

 <combobox name="cmb" width="200" height="20" displaymemberpath="personname" selectedvaluepath="personid">      </combobox> 

please notice , have removed itemtemplate part

and model below

public class person {     public string personname { get; set; }      public string personid { get; set; } } 

and binding in code behind , step not necessary , can in xaml , iam checking dirty code

 public list<person> source = new list<person>();     public mainwindow()     {         initializecomponent();           (int = 0; < 20; i++)         {             source.add(new person() { personid = i.tostring(), personname = "sau" + i.tostring() });         }         cmb.itemssource = source;         this.datacontext = this;     } 

so if run sample , see can select value when click on text itself.

it's content property causes problem not 100% sure on this.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -