10. (Don??™t click Finish, because you want to define your data template next.)
4. Define the Data Template by clicking the Define Data Template button at the bottom of
the Create Data Binding dialog box, and deselecting the data fields that you don??™t want to
appear in your list box item. Also, change the Image field from Text to Image in the dropdown
list. Then click OK. Your Blend workspace should look something like Figure
21.11, with yellow borders around ItemsSource and DataContext.
5. To edit the template of the list box, first select the combo box and change the
SelectedIndex property from -1 to 0. Then select the list box, and do the same. This
allows you to view data in the list box, and makes it much easier to edit the template.
Then select the list box and choose Edit Other Templates ??? Edit Generated Items (Item
Template) ??? Edit Template.
610
Coding, Data Binding, and XAML Part VI
FIGURE 21.10
Data binding the ItemsSource property to the Story (Array) in the Explicit Data Context
tab.
FIGURE 21.11
Data binding the ItemsSource property to the Story (Array) in the Explicit Data Context
tab.
611
Data Binding 21
6. You can change the layout panel from a stack panel to a grid by selecting [StackPanel] in
the Objects list, right-clicking on it and, from the pop-up menu that appears, choosing
Change Layout Type ??? Grid.
Pages:
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849