xaml - WPF binding to data context -
why xaml binding succeeds in view model:
private string _teststr = "test"; public string teststr { { return _teststr; } } but not this:
public string teststr = "test"; am missing something?
thanks.
because field not valid binding source:
common language runtime (clr) objects
you can bind public properties, sub-properties, indexers, of common language runtime (clr) object. binding engine uses clr reflection values of properties. alternatively, objects implement icustomtypedescriptor or have registered typedescriptionprovider work binding engine.
dynamic objects
you can bind available properties , indexers of object implements idynamicmetaobjectprovider interface. if can access member in code, can bind it.
ado.net objects
you can bind ado.net objects, such datatable. ado.net dataview implements ibindinglist interface, provides change notifications binding engine listens for.
xml objects
you can bind , run xpath queries on xmlnode, xmldocument, or xmlelement. convenient way access xml data binding source in markup use xmldataprovider object. can bind xelement or xdocument, or bind results of queries run on objects of these types using linq xml. convenient way use linq xml access xml data binding source in markup use objectdataprovider object.
dependencyobject objects
you can bind dependency properties of dependencyobject.
Comments
Post a Comment