Automatic Data Binding
- 2 minutes to read
NavBar has a built-in ability to automatically retrieve data from a data source that supports the IHierarchicalEnumerable or IHierarchicalDataSource interface. This topic describes the conditions that allow NavBar to bind automatically.
NavBar can recognize data items, and retrieve some group and item characteristics from the data fields named in a specific way. If however, any of the data-related properties of a NavBar (such as TextField, ImageUrlField, etc.) have been set, then the mapping of the associated object properties will proceed according to Data Binding Using Mapping Properties.
#Data fields and group/item properties name match
During binding, NavBar implements its automatic binding ability by retrieving group/item characteristics from those data fields whose names coincide with certain property names of a MVCxNavBarGroup or MVCxNavBarItem object. The tables below list the names of the object properties that can be mapped during automatic binding, and the matching data field names you should use in the data source for mapping to work.
Data field names | Group properties that can be set automatically |
---|---|
Enabled | Nav |
Expanded | Nav |
Header |
Image |
Name | Nav |
Navigate |
Nav |
Target | Nav |
Text | Nav |
Tool |
Nav |
Visible | Nav |
Data field names | Item properties that can be set automatically |
---|---|
Enabled | Nav |
Image |
Image |
Name | Nav |
Navigate |
Nav |
Selected | Nav |
Target | Nav |
Text | Nav |
Tool |
Nav |
Visible | Nav |
The following image illustrates the process of data retrieval during automatic binding to a particular type of data source - XmlDataSource.
#Binding to a Site Map
Since the properties of a SiteMapNode object have specific names, NavBar is designed to automatically bind to a Site Map source with node attributes of similar names. In the binding process, corresponding properties of individual MVCxNavBarGroup and MVCxNavBarItem objects are automatically associated with these item attributes, and mapped accordingly. See the table below for name correspondence.
Site Map node attributes | Corresponding Group object properties | Corresponding Item object properties |
---|---|---|
Description | MVCx |
MVCx |
Title | MVCx |
MVCx |
Url | MVCx |
MVCx |
Note
The structure of a Site Map allows some flexibility in the naming of item attributes. After Nav