SlideShare a Scribd company logo
WPF: Working With Data




     Learn More @ http://www.learnnowonline.com
        Copyright © by Application Developers Training Company
Objectives




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Objectives
• Set how to retrieve data from a SQL
  Server database




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Objectives
• Set how to retrieve data from a SQL
  Server database
• Create common data bound forms




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Objectives
• Set how to retrieve data from a SQL
  Server database
• Create common data bound forms
• See how to display information from
  main and related tables




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Agenda
• Data Binding




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Agenda
• Data Binding
• Using Views




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Data Binding




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Data Binding
• Process of getting information from
  one object to another and
  automatically displaying it in one or
  more elements in user interface




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Without Data Binding




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Without Data Binding
1. In window’s Loaded event handler,
   query database and retrieve list of
   customers




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Without Data Binding
1. In window’s Loaded event handler,
   query database and retrieve list of
   customers
2. In code or in XAML, set ItemsSource
   property of list box to DataTable or
   other object that contains customers



         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Without Data Binding
1. In window’s Loaded event handler,
   query database and retrieve list of
   customers
2. In code or in XAML, set ItemsSource
   property of list box to DataTable or
   other object that contains customers
3. In list box’s SelectionChanged event
   handler, query database and retrieve
   information for selected customer
         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Without Data Binding




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Without Data Binding
4. In list box’s SelectionChanged event
   handler, set Text property of each
   text box to value of appropriate
   column of customer data




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Without Data Binding
4. In list box’s SelectionChanged event
   handler, set Text property of each
   text box to value of appropriate
   column of customer data
5. In Save button’s Click event handler,
   read value of each text box and
   update appropriate column of
   customer data

          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Without Data Binding
4. In list box’s SelectionChanged event
   handler, set Text property of each
   text box to value of appropriate
   column of customer data
5. In Save button’s Click event handler,
   read value of each text box and
   update appropriate column of
   customer data
6. In Save button’s Click event handler,
   save changes http://www.learnnowonline.com
            Learn More @ back to database
             Copyright © by Application Developers Training Company
With Data Binding




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
With Data Binding
1. In window’s Loaded event handler, query
  database and retrieve list of customers




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
With Data Binding
1. In window’s Loaded event handler, query
   database and retrieve list of customers
2. In code or in XAML, set ItemsSource
   property of list box to DataTable or other
   object that contains customers




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
With Data Binding
1. In window’s Loaded event handler, query
   database and retrieve list of customers
2. In code or in XAML, set ItemsSource
   property of list box to DataTable or other
   object that contains customers
3. In list box’s SelectionChanged event
   handler, query database and retrieve
   information for selected customer



          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
With Data Binding
1. In window’s Loaded event handler, query
   database and retrieve list of customers
2. In code or in XAML, set ItemsSource
   property of list box to DataTable or other
   object that contains customers
3. In list box’s SelectionChanged event
   handler, query database and retrieve
   information for selected customer
4. In Save button’s Click event handler, save
   changes back to database

          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Data Source Options




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Data Source Options
• Same as in Windows Forms applications




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Data Source Options
• Same as in Windows Forms applications
• Many data sources




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Data Source Options
• Same as in Windows Forms applications
• Many data sources
  • Custom business objects




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Data Source Options
• Same as in Windows Forms applications
• Many data sources
  • Custom business objects
  • ADO.NET DataSets




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Data Source Options
• Same as in Windows Forms applications
• Many data sources
  • Custom business objects
  • ADO.NET DataSets
  • LINQ to SQL




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Data Source Options
• Same as in Windows Forms applications
• Many data sources
  •   Custom business objects
  •   ADO.NET DataSets
  •   LINQ to SQL
  •   Entity Framework




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Data Source Options
• Same as in Windows Forms applications
• Many data sources
  •   Custom business objects
  •   ADO.NET DataSets
  •   LINQ to SQL
  •   Entity Framework
  •   Services




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Data Source Options
• Same as in Windows Forms applications
• Many data sources
  •   Custom business objects
  •   ADO.NET DataSets
  •   LINQ to SQL
  •   Entity Framework
  •   Services
      • Web services




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Data Source Options
• Same as in Windows Forms applications
• Many data sources
  •   Custom business objects
  •   ADO.NET DataSets
  •   LINQ to SQL
  •   Entity Framework
  •   Services
      • Web services
      • Windows Communication Foundation (WCF)
        services

             Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Binding to an Object




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Binding to an Object
• Display clients in a list box
  • Create collection of clients in code
  • Populate the collection
  • Bind to object in XAML




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Binding to an Object
• Display clients in a list box
  • Create collection of clients in code
  • Populate the collection
  • Bind to object in XAML




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Binding to an Object
• Display clients in a list box
   • Create collection of clients in code
   • Populate the collection
   • Bind to object in XAML

<ListBox




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Binding to an Object
• Display clients in a list box
   • Create collection of clients in code
   • Populate the collection
   • Bind to object in XAML

<ListBox
 Name="listBox1"




             Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Binding to an Object
• Display clients in a list box
   • Create collection of clients in code
   • Populate the collection
   • Bind to object in XAML

<ListBox
 Name="listBox1"
 DisplayMemberPath="Name"
 ItemsSource=




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Binding to an Object
• Display clients in a list box
   • Create collection of clients in code
   • Populate the collection
   • Bind to object in XAML

<ListBox
 Name="listBox1"
 DisplayMemberPath="Name"
 ItemsSource=
    "{Binding ElementName=bindingToObject,
           Path=Clients}" />

              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Binding to an Object




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Binding to an Object
• Select a client and display details in data-
  bound text boxes in a grid
  • Bind grid by setting data context to selected
    list box item
  • Text boxes in grid inherit data binding




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Binding to an Object
• Select a client and display details in data-
  bound text boxes in a grid
  • Bind grid by setting data context to selected
    list box item
  • Text boxes in grid inherit data binding




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Binding to an Object
• Select a client and display details in data-
  bound text boxes in a grid
   • Bind grid by setting data context to selected
     list box item
   • Text boxes in grid inherit data binding
<Grid Grid.Row="1" DataContext=




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Binding to an Object
• Select a client and display details in data-
  bound text boxes in a grid
   • Bind grid by setting data context to selected
     list box item
   • Text boxes in grid inherit data binding
<Grid Grid.Row="1" DataContext=
 "{Binding ElementName=listBox1,




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Binding to an Object
• Select a client and display details in data-
  bound text boxes in a grid
   • Bind grid by setting data context to selected
     list box item
   • Text boxes in grid inherit data binding
<Grid Grid.Row="1" DataContext=
 "{Binding ElementName=listBox1,
 Path=SelectedItem}" >




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Binding to an Object
• Select a client and display details in data-
  bound text boxes in a grid
   • Bind grid by setting data context to selected
     list box item
   • Text boxes in grid inherit data binding
<Grid Grid.Row="1" DataContext=
 "{Binding ElementName=listBox1,
 Path=SelectedItem}" >
<TextBox Text="{Binding Path=Name}"




               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Binding to an Object
• Select a client and display details in data-
  bound text boxes in a grid
   • Bind grid by setting data context to selected
     list box item
   • Text boxes in grid inherit data binding
<Grid Grid.Row="1" DataContext=
 "{Binding ElementName=listBox1,
 Path=SelectedItem}" >
<TextBox Text="{Binding Path=Name}"
      Grid.Row="0" Grid.Column="1"



               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Binding to an Object
• Select a client and display details in data-
  bound text boxes in a grid
   • Bind grid by setting data context to selected
     list box item
   • Text boxes in grid inherit data binding
<Grid Grid.Row="1" DataContext=
 "{Binding ElementName=listBox1,
 Path=SelectedItem}" >
<TextBox Text="{Binding Path=Name}"
      Grid.Row="0" Grid.Column="1"
     Margin="5,5,10,5" MaxHeight="25" />

               Learn More @ http://www.learnnowonline.com
                  Copyright © by Application Developers Training Company
Binding to a DataTable




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Binding to a DataTable
• Display customers in a list box and details
  for selected customer in text boxes in grid




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Binding to a DataTable
• Display customers in a list box and details
  for selected customer in text boxes in grid
  • Use TableAdapter or intermediary data layer
    to retrieve customers and store in DataTable




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Binding to a DataTable
• Display customers in a list box and details
  for selected customer in text boxes in grid
  • Use TableAdapter or intermediary data layer
    to retrieve customers and store in DataTable
  • Set ItemsSource property of list box to
    Customers table




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Binding to a DataTable
• Display customers in a list box and details
  for selected customer in text boxes in grid
  • Use TableAdapter or intermediary data layer
    to retrieve customers and store in DataTable
  • Set ItemsSource property of list box to
    Customers table
  • Grid data context is set to list box selected
    item




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Binding to a DataTable
• Display customers in a list box and details
  for selected customer in text boxes in grid
  • Use TableAdapter or intermediary data layer
    to retrieve customers and store in DataTable
  • Set ItemsSource property of list box to
    Customers table
  • Grid data context is set to list box selected
    item
     • Text boxes automatically update when a customer
      is selected


            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Binding to a DataTable
• Display customers in a list box and details
  for selected customer in text boxes in grid
  • Use TableAdapter or intermediary data layer
    to retrieve customers and store in DataTable
  • Set ItemsSource property of list box to
    Customers table
  • Grid data context is set to list box selected
    item
     • Text boxes automatically update when a customer
      is selected
  • List box SelectionChanged event handler runs

            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Binding to a LINQ Query




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Binding to a LINQ Query
• Display customers in a list box and
  details for selected customer in text
  boxes in grid




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Binding to a LINQ Query
• Display customers in a list box and
  details for selected customer in text
  boxes in grid
  • Run LINQ to SQL query to retrieve
   customers




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Binding to a LINQ Query
• Display customers in a list box and
  details for selected customer in text
  boxes in grid
  • Run LINQ to SQL query to retrieve
    customers
  • Set ItemsSource property of results of
    query




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Binding to a LINQ Query
• Display customers in a list box and
  details for selected customer in text
  boxes in grid
  • Run LINQ to SQL query to retrieve
    customers
  • Set ItemsSource property of results of
    query
  • Grid data context is set to list box
    selected item


          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Binding to a LINQ Query
• Display customers in a list box and
  details for selected customer in text
  boxes in grid
  • Run LINQ to SQL query to retrieve
    customers
  • Set ItemsSource property of results of
    query
  • Grid data context is set to list box
    selected item
    • Text boxes automatically update when a

          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Binding to One Row of Data




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Binding to One Row of Data
• Display information on a product when
  user enters product id and clicks Find
  button




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Binding to One Row of Data
• Display information on a product when
  user enters product id and clicks Find
  button
  • Use TableAdapter or LINQ to SQL query to
   retrieve information on a product




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Binding to One Row of Data
• Display information on a product when
  user enters product id and clicks Find
  button
  • Use TableAdapter or LINQ to SQL query to
    retrieve information on a product
  • Set data context of grid to row in
    DataTable or result of LINQ query



          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Demos




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Demos
• Binding to an Object




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Demos
• Binding to an Object
• Binding to a DataTable




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Demos
• Binding to an Object
• Binding to a DataTable
• Binding to a LINQ Query




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Demos
•   Binding   to   an Object
•   Binding   to   a DataTable
•   Binding   to   a LINQ Query
•   Binding   to   One Row of Data




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Agenda




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Agenda
• Data Binding




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• Data Binding
• Using Views




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Using Views




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Using Views
• When you bind to a collection, WPF
  creates a collection view




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Using Views
• When you bind to a collection, WPF
  creates a collection view
  • View manages currency (position of
   current item)




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Using Views
• When you bind to a collection, WPF
  creates a collection view
  • View manages currency (position of
    current item)
  • Use view to navigate, sort, filter, group




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Using Views
• When you bind to a collection, WPF
  creates a collection view
  • View manages currency (position of
    current item)
  • Use view to navigate, sort, filter, group
• In code, use instance of CollectionView
  class



          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Using Views
• When you bind to a collection, WPF
  creates a collection view
  • View manages currency (position of
    current item)
  • Use view to navigate, sort, filter, group
• In code, use instance of CollectionView
  class
• To get reference to CollectionView, call
  GetDefaultView method of
          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
CollectionView Class




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
CollectionView Class
• Navigation




          Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
CollectionView Class
• Navigation
  • Methods: MoveCurrentToFirst,
   MoveCurrentToPrevious, MoveCurrentToNext,
   MoveCurrentToLast




          Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
CollectionView Class
• Navigation
  • Methods: MoveCurrentToFirst,
    MoveCurrentToPrevious, MoveCurrentToNext,
    MoveCurrentToLast
  • Properties: CurrentItem, CurrentPosition




          Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
CollectionView Class
• Navigation
  • Methods: MoveCurrentToFirst,
    MoveCurrentToPrevious, MoveCurrentToNext,
    MoveCurrentToLast
  • Properties: CurrentItem, CurrentPosition
• Sorting




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
CollectionView Class
• Navigation
  • Methods: MoveCurrentToFirst,
    MoveCurrentToPrevious, MoveCurrentToNext,
    MoveCurrentToLast
  • Properties: CurrentItem, CurrentPosition
• Sorting
  • SortDescriptions property contains collection
    of SortDescription structures




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
CollectionView Class
• Navigation
  • Methods: MoveCurrentToFirst,
    MoveCurrentToPrevious, MoveCurrentToNext,
    MoveCurrentToLast
  • Properties: CurrentItem, CurrentPosition
• Sorting
  • SortDescriptions property contains collection
    of SortDescription structures
  • SortDescription specifies column to sort on
    and order


            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
CollectionView Class
• Navigation
  • Methods: MoveCurrentToFirst,
    MoveCurrentToPrevious, MoveCurrentToNext,
    MoveCurrentToLast
  • Properties: CurrentItem, CurrentPosition
• Sorting
  • SortDescriptions property contains collection
    of SortDescription structures
  • SortDescription specifies column to sort on
    and order
  • SortDescriptions.Add adds a sorting order


            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
CollectionView Class
• Navigation
  • Methods: MoveCurrentToFirst,
    MoveCurrentToPrevious, MoveCurrentToNext,
    MoveCurrentToLast
  • Properties: CurrentItem, CurrentPosition
• Sorting
  • SortDescriptions property contains collection
    of SortDescription structures
  • SortDescription specifies column to sort on
    and order
  • SortDescriptions.Add adds a sorting order
  • SortDescriptions.Clear clears sorting
            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
CollectionView Class




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
CollectionView Class
• Filtering




          Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
CollectionView Class
• Filtering
  • Cast view to BindingListCollection




          Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
CollectionView Class
• Filtering
  • Cast view to BindingListCollection
  • Set CustomFilter property of
    BindingListCollection to filter expression




          Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
CollectionView Class
• Filtering
  • Cast view to BindingListCollection
  • Set CustomFilter property of
    BindingListCollection to filter expression
  • Set CustomFilter to empty string to clear
    filter




          Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
CollectionViewSource




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code
<Window.Resources>




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code
<Window.Resources>
 <local:NorthwindDataSet




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code
<Window.Resources>
 <local:NorthwindDataSet
  x:Key="northwindDataSet" />




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code
<Window.Resources>
 <local:NorthwindDataSet
  x:Key="northwindDataSet" />
 <CollectionViewSource




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code
<Window.Resources>
 <local:NorthwindDataSet
  x:Key="northwindDataSet" />
 <CollectionViewSource
  x:Key="customersViewSource"




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code
<Window.Resources>
 <local:NorthwindDataSet
  x:Key="northwindDataSet" />
 <CollectionViewSource
  x:Key="customersViewSource"
  Source="{Binding Path=Customers,




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code
<Window.Resources>
 <local:NorthwindDataSet
  x:Key="northwindDataSet" />
 <CollectionViewSource
  x:Key="customersViewSource"
  Source="{Binding Path=Customers,
       Source={StaticResource


              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code
<Window.Resources>
 <local:NorthwindDataSet
  x:Key="northwindDataSet" />
 <CollectionViewSource
  x:Key="customersViewSource"
  Source="{Binding Path=Customers,
       Source={StaticResource
       northwindDataSet}}" />

              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
CollectionViewSource
• XAML representation of view
• Can define views in XAML rather than
  in code
<Window.Resources>
 <local:NorthwindDataSet
  x:Key="northwindDataSet" />
 <CollectionViewSource
  x:Key="customersViewSource"
  Source="{Binding Path=Customers,
       Source={StaticResource
       northwindDataSet}}" />
</Window.Resources>
              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Demos




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Demos
• Using a CollectionView




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Demos
• Using a CollectionView
• Using a CollectionViewSource




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Drag and Drop Data Binding




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Drag and Drop Data Binding
• Drag and drop data binding supported
  in Windows Forms since Visual Studio
  2005




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Drag and Drop Data Binding
• Drag and drop data binding supported
  in Windows Forms since Visual Studio
  2005
• Now supported in WPF




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Drag and Drop Data Binding
• Drag and drop data binding supported
  in Windows Forms since Visual Studio
  2005
• Now supported in WPF
• Visual Studio creates
  CollectionViewSources in XAML when
  you drag data onto a window


         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Drag and Drop Data Binding
• Drag and drop data binding supported
  in Windows Forms since Visual Studio
  2005
• Now supported in WPF
• Visual Studio creates
  CollectionViewSources in XAML when
  you drag data onto a window
• One-to-many relationships
  automatically handled
         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Demo




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Demo
• Drag and Drop Data Binding




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Learn More!




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!


• Learn more about WPF on SlideShare:




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!


• Learn more about WPF on SlideShare:
   Intro to Windows Presentation Foundation
    (WPF)




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!


• Learn more about WPF on SlideShare:
   Intro to Windows Presentation Foundation
    (WPF)
   WPF: Advanced Controls




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!


• Learn more about WPF on SlideShare:
   Intro to Windows Presentation Foundation
    (WPF)
   WPF: Advanced Controls
   WPF: Binding




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company

More Related Content

What's hot (20)

PPTX
2014 08-15 - Getting Started with Office 365 - Office 365 Ramp Up
Dan Usher
 
PPTX
Get started with building native mobile apps interacting with SharePoint
Yaroslav Pentsarskyy [MVP]
 
PPTX
Fundamentals Of Search
Search Tools Consulting
 
PPTX
SharePoint Connections Coast to Coast Overview of Enterprise Content Management
Ivan Sanders
 
PDF
Endeca - Promoting Content & Configuration from Staging to Production
Keyur Shah
 
PPTX
B365 saturday practical guide to building a scalable search architecture in s...
Thuan Ng
 
PDF
Spring 18 Release Webinar Deck
brightgenss
 
PDF
SharePoint Fest Chicago 2014 - Anatomy of SharePoint and Office 365 Hybrid De...
Nik Patel
 
PPTX
Oracle WebCenter Content User Training
virkmasood
 
PPTX
SharePoint 2013 Search - Whats new for End Users
Mark Stokes
 
PPTX
Cloud Hybrid Search with SharePoint
Jeff Fried
 
PPTX
SPSBE building an faq for end users
Paul Hunt
 
PPTX
SharePoint Document Management
MJ Ferdous
 
PPTX
SPCA2013 - Best Practices Document Management in SharePoint (Online) 2013
Jasper Oosterveld
 
PPTX
Moving mountains with Sharepoint - Document Management with SharePoint 2013
Oliver Wirkus
 
PPTX
SharePoint 2016 Hybrid Overview
Roy Kim
 
PPTX
Sitecore xPlatform - Introduction
Thomas Eldblom
 
PPTX
SharePoint 2013 Document Management Out of the Box
Ed Musters
 
PPT
PoolParty Thesaurus Management Quick Overview
Andreas Blumauer
 
PPTX
Share point development 101
Becky Bertram
 
2014 08-15 - Getting Started with Office 365 - Office 365 Ramp Up
Dan Usher
 
Get started with building native mobile apps interacting with SharePoint
Yaroslav Pentsarskyy [MVP]
 
Fundamentals Of Search
Search Tools Consulting
 
SharePoint Connections Coast to Coast Overview of Enterprise Content Management
Ivan Sanders
 
Endeca - Promoting Content & Configuration from Staging to Production
Keyur Shah
 
B365 saturday practical guide to building a scalable search architecture in s...
Thuan Ng
 
Spring 18 Release Webinar Deck
brightgenss
 
SharePoint Fest Chicago 2014 - Anatomy of SharePoint and Office 365 Hybrid De...
Nik Patel
 
Oracle WebCenter Content User Training
virkmasood
 
SharePoint 2013 Search - Whats new for End Users
Mark Stokes
 
Cloud Hybrid Search with SharePoint
Jeff Fried
 
SPSBE building an faq for end users
Paul Hunt
 
SharePoint Document Management
MJ Ferdous
 
SPCA2013 - Best Practices Document Management in SharePoint (Online) 2013
Jasper Oosterveld
 
Moving mountains with Sharepoint - Document Management with SharePoint 2013
Oliver Wirkus
 
SharePoint 2016 Hybrid Overview
Roy Kim
 
Sitecore xPlatform - Introduction
Thomas Eldblom
 
SharePoint 2013 Document Management Out of the Box
Ed Musters
 
PoolParty Thesaurus Management Quick Overview
Andreas Blumauer
 
Share point development 101
Becky Bertram
 

Viewers also liked (6)

PPT
Windows 8: Shapes and Geometries
LearnNowOnline
 
KEY
Asynchronous Programming
LearnNowOnline
 
PPT
New in the Visual Studio 2012 IDE
LearnNowOnline
 
KEY
WPF Binding
LearnNowOnline
 
PPT
SQL: Permissions and Data Protection
LearnNowOnline
 
KEY
Attributes, reflection, and dynamic programming
LearnNowOnline
 
Windows 8: Shapes and Geometries
LearnNowOnline
 
Asynchronous Programming
LearnNowOnline
 
New in the Visual Studio 2012 IDE
LearnNowOnline
 
WPF Binding
LearnNowOnline
 
SQL: Permissions and Data Protection
LearnNowOnline
 
Attributes, reflection, and dynamic programming
LearnNowOnline
 
Ad

Similar to WPF: Working with Data (20)

KEY
The Entity Data Model
LearnNowOnline
 
KEY
Introducing LINQ
LearnNowOnline
 
KEY
What's new in Silverlight 5
LearnNowOnline
 
KEY
Using The .NET Framework
LearnNowOnline
 
KEY
Web API HTTP Pipeline
LearnNowOnline
 
KEY
Introducing the Entity Framework
LearnNowOnline
 
PDF
13088674 oracle-adf-11g-learning-application-my-procurement-application
muzaffar1986
 
KEY
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
LearnNowOnline
 
KEY
Object-Oriented JavaScript
LearnNowOnline
 
KEY
Web API Basics
LearnNowOnline
 
PPTX
Fire up your mobile app!
Suganthi Giridharan
 
KEY
.NET Variables and Data Types
LearnNowOnline
 
KEY
SharePoint: Introduction to InfoPath
LearnNowOnline
 
PPTX
Azure AD B2C Webinar Series: Custom Policies Part 1
Vinu Gunasekaran
 
PPTX
Designing a Future-proof API Program
Pronovix
 
KEY
Managing site collections
LearnNowOnline
 
PPT
Advanced Web Development
Robert J. Stein
 
PDF
MongoDB.local Berlin: App development in a Serverless World
MongoDB
 
PPTX
Dev day paris020415
pdufourSFDC
 
PPT
contentDM
spacecowboyian
 
The Entity Data Model
LearnNowOnline
 
Introducing LINQ
LearnNowOnline
 
What's new in Silverlight 5
LearnNowOnline
 
Using The .NET Framework
LearnNowOnline
 
Web API HTTP Pipeline
LearnNowOnline
 
Introducing the Entity Framework
LearnNowOnline
 
13088674 oracle-adf-11g-learning-application-my-procurement-application
muzaffar1986
 
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
LearnNowOnline
 
Object-Oriented JavaScript
LearnNowOnline
 
Web API Basics
LearnNowOnline
 
Fire up your mobile app!
Suganthi Giridharan
 
.NET Variables and Data Types
LearnNowOnline
 
SharePoint: Introduction to InfoPath
LearnNowOnline
 
Azure AD B2C Webinar Series: Custom Policies Part 1
Vinu Gunasekaran
 
Designing a Future-proof API Program
Pronovix
 
Managing site collections
LearnNowOnline
 
Advanced Web Development
Robert J. Stein
 
MongoDB.local Berlin: App development in a Serverless World
MongoDB
 
Dev day paris020415
pdufourSFDC
 
contentDM
spacecowboyian
 
Ad

More from LearnNowOnline (11)

KEY
A tour of SQL Server
LearnNowOnline
 
KEY
Generics
LearnNowOnline
 
KEY
Object oriented techniques
LearnNowOnline
 
KEY
SQL Server: Security
LearnNowOnline
 
KEY
Sql 2012 development and programming
LearnNowOnline
 
KEY
KnockOutJS with ASP.NET MVC
LearnNowOnline
 
KEY
Expression Blend Motion & Interaction Design
LearnNowOnline
 
KEY
Introduction to ASP.NET MVC
LearnNowOnline
 
KEY
Working with Controllers and Actions in MVC
LearnNowOnline
 
KEY
Creating a User Interface
LearnNowOnline
 
KEY
.Net branching and flow control
LearnNowOnline
 
A tour of SQL Server
LearnNowOnline
 
Generics
LearnNowOnline
 
Object oriented techniques
LearnNowOnline
 
SQL Server: Security
LearnNowOnline
 
Sql 2012 development and programming
LearnNowOnline
 
KnockOutJS with ASP.NET MVC
LearnNowOnline
 
Expression Blend Motion & Interaction Design
LearnNowOnline
 
Introduction to ASP.NET MVC
LearnNowOnline
 
Working with Controllers and Actions in MVC
LearnNowOnline
 
Creating a User Interface
LearnNowOnline
 
.Net branching and flow control
LearnNowOnline
 

Recently uploaded (20)

PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Python basic programing language for automation
DanialHabibi2
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 

WPF: Working with Data

  • 1. WPF: Working With Data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 2. Objectives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 3. Objectives • Set how to retrieve data from a SQL Server database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 4. Objectives • Set how to retrieve data from a SQL Server database • Create common data bound forms Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 5. Objectives • Set how to retrieve data from a SQL Server database • Create common data bound forms • See how to display information from main and related tables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 6. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 7. Agenda • Data Binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 8. Agenda • Data Binding • Using Views Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 9. Data Binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 10. Data Binding • Process of getting information from one object to another and automatically displaying it in one or more elements in user interface Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 11. Without Data Binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 12. Without Data Binding 1. In window’s Loaded event handler, query database and retrieve list of customers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 13. Without Data Binding 1. In window’s Loaded event handler, query database and retrieve list of customers 2. In code or in XAML, set ItemsSource property of list box to DataTable or other object that contains customers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 14. Without Data Binding 1. In window’s Loaded event handler, query database and retrieve list of customers 2. In code or in XAML, set ItemsSource property of list box to DataTable or other object that contains customers 3. In list box’s SelectionChanged event handler, query database and retrieve information for selected customer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 15. Without Data Binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 16. Without Data Binding 4. In list box’s SelectionChanged event handler, set Text property of each text box to value of appropriate column of customer data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 17. Without Data Binding 4. In list box’s SelectionChanged event handler, set Text property of each text box to value of appropriate column of customer data 5. In Save button’s Click event handler, read value of each text box and update appropriate column of customer data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 18. Without Data Binding 4. In list box’s SelectionChanged event handler, set Text property of each text box to value of appropriate column of customer data 5. In Save button’s Click event handler, read value of each text box and update appropriate column of customer data 6. In Save button’s Click event handler, save changes http://www.learnnowonline.com Learn More @ back to database Copyright © by Application Developers Training Company
  • 19. With Data Binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 20. With Data Binding 1. In window’s Loaded event handler, query database and retrieve list of customers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 21. With Data Binding 1. In window’s Loaded event handler, query database and retrieve list of customers 2. In code or in XAML, set ItemsSource property of list box to DataTable or other object that contains customers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 22. With Data Binding 1. In window’s Loaded event handler, query database and retrieve list of customers 2. In code or in XAML, set ItemsSource property of list box to DataTable or other object that contains customers 3. In list box’s SelectionChanged event handler, query database and retrieve information for selected customer Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 23. With Data Binding 1. In window’s Loaded event handler, query database and retrieve list of customers 2. In code or in XAML, set ItemsSource property of list box to DataTable or other object that contains customers 3. In list box’s SelectionChanged event handler, query database and retrieve information for selected customer 4. In Save button’s Click event handler, save changes back to database Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 24. Data Source Options Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 25. Data Source Options • Same as in Windows Forms applications Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 26. Data Source Options • Same as in Windows Forms applications • Many data sources Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 27. Data Source Options • Same as in Windows Forms applications • Many data sources • Custom business objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 28. Data Source Options • Same as in Windows Forms applications • Many data sources • Custom business objects • ADO.NET DataSets Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 29. Data Source Options • Same as in Windows Forms applications • Many data sources • Custom business objects • ADO.NET DataSets • LINQ to SQL Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 30. Data Source Options • Same as in Windows Forms applications • Many data sources • Custom business objects • ADO.NET DataSets • LINQ to SQL • Entity Framework Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 31. Data Source Options • Same as in Windows Forms applications • Many data sources • Custom business objects • ADO.NET DataSets • LINQ to SQL • Entity Framework • Services Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 32. Data Source Options • Same as in Windows Forms applications • Many data sources • Custom business objects • ADO.NET DataSets • LINQ to SQL • Entity Framework • Services • Web services Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 33. Data Source Options • Same as in Windows Forms applications • Many data sources • Custom business objects • ADO.NET DataSets • LINQ to SQL • Entity Framework • Services • Web services • Windows Communication Foundation (WCF) services Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 34. Binding to an Object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 35. Binding to an Object • Display clients in a list box • Create collection of clients in code • Populate the collection • Bind to object in XAML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 36. Binding to an Object • Display clients in a list box • Create collection of clients in code • Populate the collection • Bind to object in XAML Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 37. Binding to an Object • Display clients in a list box • Create collection of clients in code • Populate the collection • Bind to object in XAML <ListBox Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 38. Binding to an Object • Display clients in a list box • Create collection of clients in code • Populate the collection • Bind to object in XAML <ListBox Name="listBox1" Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 39. Binding to an Object • Display clients in a list box • Create collection of clients in code • Populate the collection • Bind to object in XAML <ListBox Name="listBox1" DisplayMemberPath="Name" ItemsSource= Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 40. Binding to an Object • Display clients in a list box • Create collection of clients in code • Populate the collection • Bind to object in XAML <ListBox Name="listBox1" DisplayMemberPath="Name" ItemsSource= "{Binding ElementName=bindingToObject, Path=Clients}" /> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 41. Binding to an Object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 42. Binding to an Object • Select a client and display details in data- bound text boxes in a grid • Bind grid by setting data context to selected list box item • Text boxes in grid inherit data binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 43. Binding to an Object • Select a client and display details in data- bound text boxes in a grid • Bind grid by setting data context to selected list box item • Text boxes in grid inherit data binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 44. Binding to an Object • Select a client and display details in data- bound text boxes in a grid • Bind grid by setting data context to selected list box item • Text boxes in grid inherit data binding <Grid Grid.Row="1" DataContext= Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 45. Binding to an Object • Select a client and display details in data- bound text boxes in a grid • Bind grid by setting data context to selected list box item • Text boxes in grid inherit data binding <Grid Grid.Row="1" DataContext= "{Binding ElementName=listBox1, Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 46. Binding to an Object • Select a client and display details in data- bound text boxes in a grid • Bind grid by setting data context to selected list box item • Text boxes in grid inherit data binding <Grid Grid.Row="1" DataContext= "{Binding ElementName=listBox1, Path=SelectedItem}" > Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 47. Binding to an Object • Select a client and display details in data- bound text boxes in a grid • Bind grid by setting data context to selected list box item • Text boxes in grid inherit data binding <Grid Grid.Row="1" DataContext= "{Binding ElementName=listBox1, Path=SelectedItem}" > <TextBox Text="{Binding Path=Name}" Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 48. Binding to an Object • Select a client and display details in data- bound text boxes in a grid • Bind grid by setting data context to selected list box item • Text boxes in grid inherit data binding <Grid Grid.Row="1" DataContext= "{Binding ElementName=listBox1, Path=SelectedItem}" > <TextBox Text="{Binding Path=Name}" Grid.Row="0" Grid.Column="1" Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 49. Binding to an Object • Select a client and display details in data- bound text boxes in a grid • Bind grid by setting data context to selected list box item • Text boxes in grid inherit data binding <Grid Grid.Row="1" DataContext= "{Binding ElementName=listBox1, Path=SelectedItem}" > <TextBox Text="{Binding Path=Name}" Grid.Row="0" Grid.Column="1" Margin="5,5,10,5" MaxHeight="25" /> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 50. Binding to a DataTable Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 51. Binding to a DataTable • Display customers in a list box and details for selected customer in text boxes in grid Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 52. Binding to a DataTable • Display customers in a list box and details for selected customer in text boxes in grid • Use TableAdapter or intermediary data layer to retrieve customers and store in DataTable Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 53. Binding to a DataTable • Display customers in a list box and details for selected customer in text boxes in grid • Use TableAdapter or intermediary data layer to retrieve customers and store in DataTable • Set ItemsSource property of list box to Customers table Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 54. Binding to a DataTable • Display customers in a list box and details for selected customer in text boxes in grid • Use TableAdapter or intermediary data layer to retrieve customers and store in DataTable • Set ItemsSource property of list box to Customers table • Grid data context is set to list box selected item Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 55. Binding to a DataTable • Display customers in a list box and details for selected customer in text boxes in grid • Use TableAdapter or intermediary data layer to retrieve customers and store in DataTable • Set ItemsSource property of list box to Customers table • Grid data context is set to list box selected item • Text boxes automatically update when a customer is selected Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 56. Binding to a DataTable • Display customers in a list box and details for selected customer in text boxes in grid • Use TableAdapter or intermediary data layer to retrieve customers and store in DataTable • Set ItemsSource property of list box to Customers table • Grid data context is set to list box selected item • Text boxes automatically update when a customer is selected • List box SelectionChanged event handler runs Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 57. Binding to a LINQ Query Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 58. Binding to a LINQ Query • Display customers in a list box and details for selected customer in text boxes in grid Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 59. Binding to a LINQ Query • Display customers in a list box and details for selected customer in text boxes in grid • Run LINQ to SQL query to retrieve customers Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 60. Binding to a LINQ Query • Display customers in a list box and details for selected customer in text boxes in grid • Run LINQ to SQL query to retrieve customers • Set ItemsSource property of results of query Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 61. Binding to a LINQ Query • Display customers in a list box and details for selected customer in text boxes in grid • Run LINQ to SQL query to retrieve customers • Set ItemsSource property of results of query • Grid data context is set to list box selected item Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 62. Binding to a LINQ Query • Display customers in a list box and details for selected customer in text boxes in grid • Run LINQ to SQL query to retrieve customers • Set ItemsSource property of results of query • Grid data context is set to list box selected item • Text boxes automatically update when a Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 63. Binding to One Row of Data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 64. Binding to One Row of Data • Display information on a product when user enters product id and clicks Find button Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 65. Binding to One Row of Data • Display information on a product when user enters product id and clicks Find button • Use TableAdapter or LINQ to SQL query to retrieve information on a product Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 66. Binding to One Row of Data • Display information on a product when user enters product id and clicks Find button • Use TableAdapter or LINQ to SQL query to retrieve information on a product • Set data context of grid to row in DataTable or result of LINQ query Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 67. Demos Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 68. Demos • Binding to an Object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 69. Demos • Binding to an Object • Binding to a DataTable Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 70. Demos • Binding to an Object • Binding to a DataTable • Binding to a LINQ Query Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 71. Demos • Binding to an Object • Binding to a DataTable • Binding to a LINQ Query • Binding to One Row of Data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 72. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 73. Agenda • Data Binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 74. Agenda • Data Binding • Using Views Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 75. Using Views Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 76. Using Views • When you bind to a collection, WPF creates a collection view Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 77. Using Views • When you bind to a collection, WPF creates a collection view • View manages currency (position of current item) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 78. Using Views • When you bind to a collection, WPF creates a collection view • View manages currency (position of current item) • Use view to navigate, sort, filter, group Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 79. Using Views • When you bind to a collection, WPF creates a collection view • View manages currency (position of current item) • Use view to navigate, sort, filter, group • In code, use instance of CollectionView class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 80. Using Views • When you bind to a collection, WPF creates a collection view • View manages currency (position of current item) • Use view to navigate, sort, filter, group • In code, use instance of CollectionView class • To get reference to CollectionView, call GetDefaultView method of Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 81. CollectionView Class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 82. CollectionView Class • Navigation Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 83. CollectionView Class • Navigation • Methods: MoveCurrentToFirst, MoveCurrentToPrevious, MoveCurrentToNext, MoveCurrentToLast Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 84. CollectionView Class • Navigation • Methods: MoveCurrentToFirst, MoveCurrentToPrevious, MoveCurrentToNext, MoveCurrentToLast • Properties: CurrentItem, CurrentPosition Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 85. CollectionView Class • Navigation • Methods: MoveCurrentToFirst, MoveCurrentToPrevious, MoveCurrentToNext, MoveCurrentToLast • Properties: CurrentItem, CurrentPosition • Sorting Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 86. CollectionView Class • Navigation • Methods: MoveCurrentToFirst, MoveCurrentToPrevious, MoveCurrentToNext, MoveCurrentToLast • Properties: CurrentItem, CurrentPosition • Sorting • SortDescriptions property contains collection of SortDescription structures Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 87. CollectionView Class • Navigation • Methods: MoveCurrentToFirst, MoveCurrentToPrevious, MoveCurrentToNext, MoveCurrentToLast • Properties: CurrentItem, CurrentPosition • Sorting • SortDescriptions property contains collection of SortDescription structures • SortDescription specifies column to sort on and order Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 88. CollectionView Class • Navigation • Methods: MoveCurrentToFirst, MoveCurrentToPrevious, MoveCurrentToNext, MoveCurrentToLast • Properties: CurrentItem, CurrentPosition • Sorting • SortDescriptions property contains collection of SortDescription structures • SortDescription specifies column to sort on and order • SortDescriptions.Add adds a sorting order Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 89. CollectionView Class • Navigation • Methods: MoveCurrentToFirst, MoveCurrentToPrevious, MoveCurrentToNext, MoveCurrentToLast • Properties: CurrentItem, CurrentPosition • Sorting • SortDescriptions property contains collection of SortDescription structures • SortDescription specifies column to sort on and order • SortDescriptions.Add adds a sorting order • SortDescriptions.Clear clears sorting Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 90. CollectionView Class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 91. CollectionView Class • Filtering Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 92. CollectionView Class • Filtering • Cast view to BindingListCollection Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 93. CollectionView Class • Filtering • Cast view to BindingListCollection • Set CustomFilter property of BindingListCollection to filter expression Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 94. CollectionView Class • Filtering • Cast view to BindingListCollection • Set CustomFilter property of BindingListCollection to filter expression • Set CustomFilter to empty string to clear filter Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 95. CollectionViewSource Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 96. CollectionViewSource • XAML representation of view Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 97. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 98. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 99. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code <Window.Resources> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 100. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code <Window.Resources> <local:NorthwindDataSet Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 101. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code <Window.Resources> <local:NorthwindDataSet x:Key="northwindDataSet" /> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 102. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code <Window.Resources> <local:NorthwindDataSet x:Key="northwindDataSet" /> <CollectionViewSource Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 103. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code <Window.Resources> <local:NorthwindDataSet x:Key="northwindDataSet" /> <CollectionViewSource x:Key="customersViewSource" Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 104. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code <Window.Resources> <local:NorthwindDataSet x:Key="northwindDataSet" /> <CollectionViewSource x:Key="customersViewSource" Source="{Binding Path=Customers, Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 105. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code <Window.Resources> <local:NorthwindDataSet x:Key="northwindDataSet" /> <CollectionViewSource x:Key="customersViewSource" Source="{Binding Path=Customers, Source={StaticResource Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 106. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code <Window.Resources> <local:NorthwindDataSet x:Key="northwindDataSet" /> <CollectionViewSource x:Key="customersViewSource" Source="{Binding Path=Customers, Source={StaticResource northwindDataSet}}" /> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 107. CollectionViewSource • XAML representation of view • Can define views in XAML rather than in code <Window.Resources> <local:NorthwindDataSet x:Key="northwindDataSet" /> <CollectionViewSource x:Key="customersViewSource" Source="{Binding Path=Customers, Source={StaticResource northwindDataSet}}" /> </Window.Resources> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 108. Demos Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 109. Demos • Using a CollectionView Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 110. Demos • Using a CollectionView • Using a CollectionViewSource Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 111. Drag and Drop Data Binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 112. Drag and Drop Data Binding • Drag and drop data binding supported in Windows Forms since Visual Studio 2005 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 113. Drag and Drop Data Binding • Drag and drop data binding supported in Windows Forms since Visual Studio 2005 • Now supported in WPF Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 114. Drag and Drop Data Binding • Drag and drop data binding supported in Windows Forms since Visual Studio 2005 • Now supported in WPF • Visual Studio creates CollectionViewSources in XAML when you drag data onto a window Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 115. Drag and Drop Data Binding • Drag and drop data binding supported in Windows Forms since Visual Studio 2005 • Now supported in WPF • Visual Studio creates CollectionViewSources in XAML when you drag data onto a window • One-to-many relationships automatically handled Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 116. Demo Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 117. Demo • Drag and Drop Data Binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 118. Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 119. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 120. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 121. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about WPF on SlideShare: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 122. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about WPF on SlideShare:  Intro to Windows Presentation Foundation (WPF) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 123. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about WPF on SlideShare:  Intro to Windows Presentation Foundation (WPF)  WPF: Advanced Controls Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 124. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! • Learn more about WPF on SlideShare:  Intro to Windows Presentation Foundation (WPF)  WPF: Advanced Controls  WPF: Binding Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company

Editor's Notes