wpf - usercontrol datacontext different usings -
when write :
<usercontrol> <usercontrol.datacontext> <loca:databindingdemo></loca:databindingdemo> </usercontrol.datacontext> <textbox text="{binding path=currenttime}" height="30" background="aqua" margin="133,141,169,140"></textbox> </usercontrol>
with xmlns:loca="clr-namespace:myclock"
it currect , there no problem,but when write:
<usercontrol datacontext="{binding source=clr-namespace:myclock.databindingdemo}"> <!-- <usercontrol.datacontext> <loca:databindingdemo></loca:databindingdemo> </usercontrol.datacontext> --> <textbox text="{binding path=currenttime}" height="30" background="aqua" margin="133,141,169,140"></textbox> </usercontrol>
or
<usercontrol datacontext="{binding source=staticresource, path=clr-namespace:myclock.databindingdemo}"> <!-- <usercontrol.datacontext> <loca:databindingdemo></loca:databindingdemo> </usercontrol.datacontext> --> <textbox text="{binding path=currenttime}" height="30" background="aqua" margin="133,141,169,140"></textbox> </usercontrol>
it not work! why?
thanks in advance.
it not work! why?
clr-namespace:
used create namespace mapping custom classes , assemblies , can't used directly in markup extension, not namespace prefix.
edit: can't use local types in assembly directly in markup extension that.
first have create namespace mapping have done in question this: xmlns:local="clr-namepsace:your_assembly_name.namespace_containing_type_you_want"
.
then can use them in markup extensions this:
<usercontrol datacontext="{binding source=local:myclock.databindingdemo}"> // ^ // | // notice namespace using here
Comments
Post a Comment