6
Using tabs to display multiple items from an XML data source.
The steps to create this data binding scenario are as follows:
STEPS: Data Binding to a Tab Control
1. Add the data source to your window by choosing Project ??? Add Existing Item or
Project ??? Link To Existing Item. Then click the +XML button in the Data palette, type in
the name of the XML file into the Add XML Data Source dialog box as it appears in the
Files palette in the Project panel, and click OK. (Or you can publish the XML file to the
Internet, and type in its URL.)
2. Drag the field with (Array) in its name from the Data palette to the artboard. When you
release the mouse choose TabControl from the context menu that appears.
3. Choose the default of ItemsSource in the Create Data Binding dialog box, and click OK.
4. In the Create Data Template dialog box, deselect all but the name (for example,
FlowerName), and click OK.
5. Using the Selection tool, resize the tab control as you want it to appear.
6. Select the LayoutRoot or parent panel of your tab control, click the Advanced Property
Options button next to the Data Context, and choose Data Binding. In the Create Data
Binding dialog box, select Element Property, select TabControl in the list on the left and
SelectedItem in the list on the right, and click Finish.
Pages:
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843