wpf - Two-way-like binding between a Resource's property and a runtime object property -
my problem following :
i have defined textbox child of toolbar in resourcedictionary (x:key mytoolbar). when application loads, places toolbar correctly inside window frame, along textbox. far, good.
of course, i'd textbox two-way databound objects' properties not defined in resourcedictionary.
more precisely, when textbox set in correct window frame, , then, after “open” command file loaded, deserializer builds designercanvas object using values out of file, in case string “token” clr property of class implements inotifypropertychanged.
here simplified code snippets. leave many blanks clarity’s sake:
class designercanvas : inotifypropertychanged
{
private string m_token; public string token { get{…. set{ if (value…) onpropertychanged(“token”); } //notice there no constructor other default 1
}
and on xaml side have this:
<toolbar x:key=”mytoolbar….. <textbox …
now, 2 goals are: have “static” textbox resource on toolbar pick values of designercanvas’ “token” property property changes (i.e. gets value first time, basically), , similarly, , more importantly, wish make possible have designercanvas read values put in manually textbox , fill token property user-input text (i think opt textbox’ lostfocus event trigger string value being passed/bound onto designercanvas’ “token” property).
anyway, i’m not sure how set perfect two-way (or two-way-like) databinding between textbox' text property , designercanvas' token property, since have 1 static resource (i’m not sure if static correct word), , dynamic runtime object (again not sure if runtime or dynamic words).
how achieve this? absolutely need register “token”- dependencyproperty in designercanvas? absolutely need have xaml designercanvas defined somewhere (for example in window1.xaml or dummy s:designercanvas resource along textbox)?
help appreciated!
have tried databinding textbox...
<textbox text="{binding path=token, mode=twoway}" />
...then when app loads , places toolbar in window frame, make sure sets datacontext property of toolbar instance of designercanvas class?
Comments
Post a Comment