Do Databinding in C# codes
Databinding in C# codes offers the more flexible way to bind UI elments to the data source at run time. The following codes snippet gives the pattern to bind UI elements to XmlDataProvider.
Binding databinding = new Binding();
databinding.Mode = BindingMode.Default/OneWay/TwoWay…;
databinding.Source = SomeDataSourceObject;
databinding.XPath = SomeXPathString;
SomeClass can be the current calling UI element’s class, like the normal controls, also can be its holder’s class, like Grid and Panel.
If you need to databind your control with CLR data object, you should specify Path instead of XPath. The usual way is:
databinding.Path = new PathProperty(PathString);