wpf - Bind textboxes in an editable combobox -


i need have editable textboxes on dropdown.

 <combobox iseditable="true"  itemtemplate="{staticresource methodtemplate}" itemssource="{binding methodnames}"                   selectedindex="0" selectedvalue="{binding selectedmethod}" verticalalignment="top" grid.column="1" grid.row="0" height="35" grid.columnspan="2" grid.rowspan="2">         </combobox>    <datatemplate x:key="methodtemplate" datatype="{x:type models:methoddetail}">             <grid>                 <grid.columndefinitions>                     <columndefinition width="1*"></columndefinition>                     <columndefinition width="2*"></columndefinition>                 </grid.columndefinitions>                 <grid.rowdefinitions>                     <rowdefinition height="2*"></rowdefinition>                 </grid.rowdefinitions>                 <!--to display selected combo values i.e method name-->                 <textblock grid.column="0" margin="5" grid.row="0" horizontalalignment="left"  text="{binding methodname}" ></textblock>                 <!--<textblock margin="5" grid.column="1" text="{binding parameters ,converter= {staticresource listtostringconverter}}"/>-->                 <itemscontrol grid.column="1">                     <stackpanel orientation="horizontal">                         <textbox margin="5" grid.column="1" text="blah"/>                         <textbox margin="5" grid.column="1" text="blah"/>                     </stackpanel>                 </itemscontrol>             </grid>         </datatemplate> 

to describe problem, have methods , parameters methods on dropdown, need bind controls (textboxes) user enter parameter values within them. when combobox not editable textboxes show up, not editable.

there few things has corrected

1.setting iseditable="true" combobox not in editing comboboxitems.
2. datatemplate should defined in resources section. either in or 3. using both selectedvalue , selectedindex @ time, not correct. 4. datatemplate not need itemscontrol in it. can manage using grid control also.

if these set right, code runs fine me. here's code:

<window x:class="minimizeapp.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindow" height="350" width="525">     <window.resources>         <datatemplate x:key="methodtemplate" >             <grid>                 <grid.columndefinitions>                     <columndefinition width="1*"></columndefinition>                     <columndefinition width="2*"></columndefinition>                 </grid.columndefinitions>                 <grid.rowdefinitions>                     <rowdefinition height="2*"></rowdefinition>                 </grid.rowdefinitions>                 <!--to display selected combo values i.e method name-->                 <textblock grid.column="0" margin="5" grid.row="0" horizontalalignment="left"  text="{binding tbproperty}" ></textblock>                 <!--<textblock margin="5" grid.column="1" text="{binding parameters ,converter= {staticresource listtostringconverter}}"/>-->                 <itemscontrol grid.column="1">                     <stackpanel orientation="horizontal">                         <textbox margin="5" grid.column="1" text="blah"/>                         <textbox margin="5" grid.column="1" text="blah"/>                     </stackpanel>                 </itemscontrol>             </grid>         </datatemplate>     </window.resources>     <grid>          <combobox iseditable="true"  itemtemplate="{staticresource methodtemplate}" itemssource="{binding methodnames}"                   selectedindex="0"  verticalalignment="top" grid.column="1" grid.row="0" height="35" grid.columnspan="2" grid.rowspan="2">         </combobox>           </grid> </window> 

if bind datacontext correctly, code should run fine. :)


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -