c# - difference when binding a Label and a TextBox (XAML) -
just found out surprised with.
xaml code:
<label content="{binding myparameter}"/> <textbox text="{binding myparameter}" />
myparameter instance of class tostring() method overridden:
public override string tostring() { console.writeline("displaying value: " + name); return name; }
when rendering: label invokes tostring() , displays name property. textbox not display anything
can explanation why?
content
expected object, means tostring()
called.
text
expected string property. if text
not bound string property, framework error handling kicks in , displays nothing.
the best practice bind directly values wish display, rather parent object. in case, bind name
property, directly.
Comments
Post a Comment