Prev | Current Page 827 | Next

Gurdy Leete and Mary Leete

"Microsoft Expression Blend Bible"


TIP
602
Coding, Data Binding, and XAML Part VI
STEPS: Data Binding Data Source Fields to Text Controls
1. Select a text block or any text control and click the Advanced Property Options button
beside the Data Context property in the Common Properties palette. (It??™s next to the New
button). Then choose Data Binding from the context menu.
2. In the Create Data Binding dialog box, click Element Property, choose the combo box in
the list on the left, choose SelectedItem in the list on the right, and click Finish.
3. Select the text block if it??™s not already selected, click the Advanced Property Options button
beside Text in the Common Properties palette, and in the Create Data Binding dialog
box, click Explicit Data Context. Choose the field that you want to display in the text
control, and click Finish.
4. Repeat steps 1-3 for each text control that you want to data bind.
A shortcut to the above steps is to data bind the Data Context field of the stack panel??”
not the text control??”to the SelectedItem field of the combo box in Step 1. Then
change Step 4 to repeat steps 2-3, instead of 1-3. The Windows Presentation Foundation looks for parents
or grandparents or other ancestors with a data bound Data Context field, and offers that as the
Explicit Data Context option.


Pages:
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839