Visual studio 2010

Page 262

Chapter 8:

Building Desktop Applications with WPF

Figure 8-15 Controls bound via a data source

This is another reason it’s important to be able to read the XAML for a window, so you can see how objects like this are added and configure them if you need to. In our case, we need to know the name of the CollectionViewSource, which is orderViewSource. We need to add an Order object to the CollectionViewSource so that the controls that are bound to it have a place to save data that the user enters. Press F7 to see the code that VS added to the Window Loaded event handler, as follows: C#: private void Window_Loaded(object sender, RoutedEventArgs e) { System.Windows.Data.CollectionViewSource orderViewSource = ((System.Windows.Data.CollectionViewSource) (this.FindResource("orderViewSource"))); // Load data by setting the //CollectionViewSource.Source property: // orderViewSource.Source = [generic data source] }

239


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.