Microsoft 9GD00001 Computer Accessories User Manual


 
Chapter 8: Building Desktop Applications with WPF 239
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]
}
Figure 8-15 Controls bound via a data source