c# - Binding a combobox selected item content to an element -


i working wpf using entity framework , data binding managing product , brand in database. product includes brandid property. in order display in datagrid brand name instead of id, used datagridcomboboxcolumn this:

c#

gridproducts.datacontext = this.dbcontext.products; brandcolumn.itemssource = this.dbcontext.brands; 

xaml

<datagrid name="gridproducts" issynchronizedwithcurrentitem="true"           roweditending="dg_roweditending" itemssource="{binding}" >   <datagrid.columns>     ...     <datagridcomboboxcolumn header="brand" x:name="brandcolumn" displaymemberpath="brandname"         selectedvaluepath="id" selectedvaluebinding="{binding path=brandid}" />  </datagrid.columns> <datagrid> 

it works fine. need bind combobox selected value textbox text. tried this:

xaml

    <textbox name="brand" text="{binding path=selectedvalue.content,        elementname=brandcolumn}"/> 

but doesn't work. idea of how can bind combobox selected value (the brandname - not brandid) in textbox?

instead of binding in xaml, create common property in entity/viewmodel , bind that.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -