c# - Combo box DisplayMember of a value -


i'm pretty new wpf , searched several sites , pages, didn't found problem:

i fill combobox values , different displaymembers

c#:

comboraum.datacontext = dtload.defaultview;         comboraum.displaymemberpath = dtload.columns["name"].tostring();         comboraum.selectedvaluepath = dtload.columns["id_room"].tostring(); 

xaml:

<combobox name="comboraum" margin="5" height="26" itemssource="{binding}"/> 

now read id_room table sqldatareader. reader works fine, other things displayed right.

sqlreaderdetails["id_room"].tostring(); 

how combobox set item same value selected item? jumps first entry.

solved it!

added

selectedvaluepath="content" 

to xaml combobox properties. can set selecteditem selectedvalue = id @ runtime.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -