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
Post a Comment