wpf - Binding to DataTemplate -
i have button template:
<datatemplate x:key="templatetest"> <button margin="10" borderthickness="2" content="{binding text}" /> </datatemplate>
i want create textbox , button content same textbox's text.
<textbox x:name="textbox" margin="10">textbox</textbox> <contentcontrol datacontext="{binding elementname=textbox}" contenttemplate="{staticresource resourcekey=templatetest}" />
but don't on button in way.
@danpuzey's 1 still did not work me in vs2012. not sure why did in kaxaml
this did:
<textbox x:name="textbox" margin="10" text="hello world" /> <contentcontrol content="{binding elementname=textbox, path=.}" contenttemplate="{staticresource templatetest}" />
and
<datatemplate x:key="templatetest"> <button height="100" margin="10" borderthickness="2" content="{binding text}" /> </datatemplate>
Comments
Post a Comment