SlideShare a Scribd company logo
1 of 20
Data binding is the mechanism by which
information contained in an object is associated
with elements in your user interface
Data binding is the process that establishes a
connection between the application UI and
business logic
 data binding is about keeping object properties
and collections of objects synchronized with one
or more controls’ views of the data
 The goal of data binding
 Save the time required to write the code to:
▪ Update controls when the data in the objects changes
▪ Update data when user edits the data in the controls
 The synchronization of the data to the controls
depends on the INotifyPropertyChanged and
INotifyCollectionChanged interfaces
 Example
 Target Object =TextBlock
 Dependency Property =Text
 Source Object = Person
 Property = Name
<Grid Name="grid" DataContext="{StaticResource Person}">
…
<TextBlockText="{Binding Path=Name}" />
</Grid>
 OneWay: Source changed Target change
 TwoWay: Source change Target change
 OneWayToSource:Target changed  Source
change
With Data Binding
Without Data Binding
 ValueConverter used to bind two properties of different types
together.
 ValueConverter converts the value from a source type to a target type
and back.
 Implementing the IValueConverter interface to create your own
ValueConverter
<Button Background="{Binding Source={StaticResource myDataSource},
Path=ColorName}">I am bound to be RED!</Button>
 We would need to create a custom converter
by implementing the IValueConverter
interface
 Collection Object must implement the
INotifyCollectionChanged interface
 Each object in collection must also implement
the INotifyPropertyChanged interface
List Data Binding
 CollectionViews are used to sort, filter, or
group the data when ItemsControl is
bounded to a data collection
 CollectionViews are classes that implement
the ICollectionView interface
 Each source collection can have multiple
views associated with it  Same data can
display in different ways
Name Type Descriptions
MoveCurrentToFirst Method Sets the first item in the view as the CurrentItem.
MoveCurrentToLast Method Sets the last item in the view as the CurrentItem.
MoveCurrentToNext Method Sets the item after the CurrentItem in the view as the CurrentItem.
MoveCurrentToPrevious Method Sets the item before the CurrentItem in the view as the CurrentItem.
CurrentItem Properties Gets the current item in the view.
Filter Properties Gets or sets a method used to determine if an item is suitable for
inclusion in the view.
Groups Properties Gets a collection of the top-level groups that is constructed based in the
GroupDescriptions property.
SortDescriptions Properties Gets a collection of SortDescription structures that describes how the
items in the collection are sorted in the view.
Using CollectionViews
 DataTemplates allow you to define
compelling visuals for your data.
 TheWPF data binding model allows
associate ValidationRules with your Binding
object
 The ValidationRules property takes a collection
of ValidationRule objects
 There are some built-in ValidationRule in WPF
▪ ExceptionValidationRule checks for exceptions thrown during
the update of the binding source property.
▪ DataErrorValidationRule object checks for errors that are
raised by objects that implement the IDataErrorInfo
interface.
 Your own validation rule must deriving from the
ValidationRule class and implementing the
Validate method
DataValidation
 Object Data Provider
 Derived from the DataSourceProvider
 Using object as Data Context
 Binding by Path property
 XML Data Source Provider
 Derived from the DataSourceProvider
 Using XML data as Data Context
 Binding by XPath property

More Related Content

What's hot

ASP.NET MVC Controllers & Actions
ASP.NET MVC Controllers & ActionsASP.NET MVC Controllers & Actions
ASP.NET MVC Controllers & Actionsonsela
 
Attached property
Attached propertyAttached property
Attached propertymsarangam
 
Configuring Data Binding part2 ABTO Software Lecture Korotchyn
Configuring Data Binding part2 ABTO Software Lecture KorotchynConfiguring Data Binding part2 ABTO Software Lecture Korotchyn
Configuring Data Binding part2 ABTO Software Lecture KorotchynABTO Software
 
Configuring Data Binding part1 ABTO Software Lecture Korotchyn
Configuring Data Binding part1 ABTO Software Lecture KorotchynConfiguring Data Binding part1 ABTO Software Lecture Korotchyn
Configuring Data Binding part1 ABTO Software Lecture KorotchynABTO Software
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesArvind Krishnaa
 
Datasource in asp.net
Datasource in asp.netDatasource in asp.net
Datasource in asp.netSireesh K
 
WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1Vikas Pandey
 
Android Training (Content Provider)
Android Training (Content Provider)Android Training (Content Provider)
Android Training (Content Provider)Khaled Anaqwa
 
Binding radgridview into reportviewer
Binding radgridview into reportviewerBinding radgridview into reportviewer
Binding radgridview into reportviewerJunifar hidayat
 
asp.net data controls
asp.net data controlsasp.net data controls
asp.net data controlssubakrish
 
Data Binding in Silverlight
Data Binding in SilverlightData Binding in Silverlight
Data Binding in SilverlightBoulos Dib
 
Android content provider explained
Android content provider explainedAndroid content provider explained
Android content provider explainedShady Selim
 
Overview Of ADO .NET from Wingslive.com
Overview Of ADO .NET from Wingslive.comOverview Of ADO .NET from Wingslive.com
Overview Of ADO .NET from Wingslive.comWings Interactive
 
SAP BO Web Intelligence Basics
SAP BO Web Intelligence BasicsSAP BO Web Intelligence Basics
SAP BO Web Intelligence BasicsKiran Joy
 

What's hot (20)

ASP.NET MVC Controllers & Actions
ASP.NET MVC Controllers & ActionsASP.NET MVC Controllers & Actions
ASP.NET MVC Controllers & Actions
 
Attached property
Attached propertyAttached property
Attached property
 
Configuring Data Binding part2 ABTO Software Lecture Korotchyn
Configuring Data Binding part2 ABTO Software Lecture KorotchynConfiguring Data Binding part2 ABTO Software Lecture Korotchyn
Configuring Data Binding part2 ABTO Software Lecture Korotchyn
 
Configuring Data Binding part1 ABTO Software Lecture Korotchyn
Configuring Data Binding part1 ABTO Software Lecture KorotchynConfiguring Data Binding part1 ABTO Software Lecture Korotchyn
Configuring Data Binding part1 ABTO Software Lecture Korotchyn
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View Classes
 
Datasource in asp.net
Datasource in asp.netDatasource in asp.net
Datasource in asp.net
 
MS Sql Server:Reporting models
MS Sql Server:Reporting modelsMS Sql Server:Reporting models
MS Sql Server:Reporting models
 
WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1
 
Ado.net
Ado.netAdo.net
Ado.net
 
Android Training (Content Provider)
Android Training (Content Provider)Android Training (Content Provider)
Android Training (Content Provider)
 
Cis266 final review
Cis266 final reviewCis266 final review
Cis266 final review
 
Binding radgridview into reportviewer
Binding radgridview into reportviewerBinding radgridview into reportviewer
Binding radgridview into reportviewer
 
asp.net data controls
asp.net data controlsasp.net data controls
asp.net data controls
 
GRID VIEW PPT
GRID VIEW PPTGRID VIEW PPT
GRID VIEW PPT
 
Salesforce talk
Salesforce talkSalesforce talk
Salesforce talk
 
Data Binding in Silverlight
Data Binding in SilverlightData Binding in Silverlight
Data Binding in Silverlight
 
Android content provider explained
Android content provider explainedAndroid content provider explained
Android content provider explained
 
Grid Vew Control VB
Grid Vew Control VBGrid Vew Control VB
Grid Vew Control VB
 
Overview Of ADO .NET from Wingslive.com
Overview Of ADO .NET from Wingslive.comOverview Of ADO .NET from Wingslive.com
Overview Of ADO .NET from Wingslive.com
 
SAP BO Web Intelligence Basics
SAP BO Web Intelligence BasicsSAP BO Web Intelligence Basics
SAP BO Web Intelligence Basics
 

Similar to Lesson 05 Data Binding in WPF

WPF - Controls &amp; Data
WPF - Controls &amp; DataWPF - Controls &amp; Data
WPF - Controls &amp; DataSharada Gururaj
 
The Magic of WPF & MVVM
The Magic of WPF & MVVMThe Magic of WPF & MVVM
The Magic of WPF & MVVMAbhishek Sur
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its featuresAbhishek Sur
 
Murach: How to transfer data from controllers
Murach: How to transfer data from controllersMurach: How to transfer data from controllers
Murach: How to transfer data from controllersMahmoudOHassouna
 
Dependency property
Dependency propertyDependency property
Dependency propertymsarangam
 
Entity framework 4.0
Entity framework 4.0Entity framework 4.0
Entity framework 4.0Abhishek Sur
 
Entity Framework - Object Services
Entity Framework -  Object ServicesEntity Framework -  Object Services
Entity Framework - Object ServicesEyal Vardi
 
Silverlight week5
Silverlight week5Silverlight week5
Silverlight week5iedotnetug
 
Flex3 data binding
Flex3 data bindingFlex3 data binding
Flex3 data bindingguestdf3003
 
SAP Business Objects 4.2 Training Online
SAP Business Objects 4.2 Training Online SAP Business Objects 4.2 Training Online
SAP Business Objects 4.2 Training Online ashok training
 
Online SAP BO 4.2 Training
Online SAP BO 4.2 TrainingOnline SAP BO 4.2 Training
Online SAP BO 4.2 Trainingashok training
 
Sap bo 4.2 course content
Sap bo 4.2 course contentSap bo 4.2 course content
Sap bo 4.2 course contentAnudeep K
 
SAP BusinessObjects Design Studio 1.7
SAP BusinessObjects Design Studio 1.7SAP BusinessObjects Design Studio 1.7
SAP BusinessObjects Design Studio 1.7Madhukar Reddy
 
Training BOBJ SAP Online
Training BOBJ SAP OnlineTraining BOBJ SAP Online
Training BOBJ SAP Onlineashok training
 
How do i connect to that
How do i connect to thatHow do i connect to that
How do i connect to thatBecky Bertram
 

Similar to Lesson 05 Data Binding in WPF (20)

WPF - Controls &amp; Data
WPF - Controls &amp; DataWPF - Controls &amp; Data
WPF - Controls &amp; Data
 
The Magic of WPF & MVVM
The Magic of WPF & MVVMThe Magic of WPF & MVVM
The Magic of WPF & MVVM
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Murach: How to transfer data from controllers
Murach: How to transfer data from controllersMurach: How to transfer data from controllers
Murach: How to transfer data from controllers
 
Dependency property
Dependency propertyDependency property
Dependency property
 
KnockoutJS and MVVM
KnockoutJS and MVVMKnockoutJS and MVVM
KnockoutJS and MVVM
 
Entity framework 4.0
Entity framework 4.0Entity framework 4.0
Entity framework 4.0
 
Entity Framework - Object Services
Entity Framework -  Object ServicesEntity Framework -  Object Services
Entity Framework - Object Services
 
Silverlight week5
Silverlight week5Silverlight week5
Silverlight week5
 
Flex3 data binding
Flex3 data bindingFlex3 data binding
Flex3 data binding
 
Ado.net
Ado.netAdo.net
Ado.net
 
SAP Business Objects 4.2 Training Online
SAP Business Objects 4.2 Training Online SAP Business Objects 4.2 Training Online
SAP Business Objects 4.2 Training Online
 
BOBJ Training Online
BOBJ Training  OnlineBOBJ Training  Online
BOBJ Training Online
 
Online SAP BO 4.2 Training
Online SAP BO 4.2 TrainingOnline SAP BO 4.2 Training
Online SAP BO 4.2 Training
 
Sap bo 4.2 course content
Sap bo 4.2 course contentSap bo 4.2 course content
Sap bo 4.2 course content
 
SAP BusinessObjects Design Studio 1.7
SAP BusinessObjects Design Studio 1.7SAP BusinessObjects Design Studio 1.7
SAP BusinessObjects Design Studio 1.7
 
Training BOBJ SAP Online
Training BOBJ SAP OnlineTraining BOBJ SAP Online
Training BOBJ SAP Online
 
How do i connect to that
How do i connect to thatHow do i connect to that
How do i connect to that
 
Oracle application-development-framework-best-practices
Oracle application-development-framework-best-practicesOracle application-development-framework-best-practices
Oracle application-development-framework-best-practices
 

More from Quang Nguyễn Bá

Lesson 08 Documents and Printings in WPF
Lesson 08 Documents and Printings in WPFLesson 08 Documents and Printings in WPF
Lesson 08 Documents and Printings in WPFQuang Nguyễn Bá
 
Lesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFLesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFQuang Nguyễn Bá
 
Lesson 02 Introduction to XAML
Lesson 02 Introduction to XAMLLesson 02 Introduction to XAML
Lesson 02 Introduction to XAMLQuang Nguyễn Bá
 
TDD - Test Driven Dvelopment | Test First Design
TDD -  Test Driven Dvelopment | Test First DesignTDD -  Test Driven Dvelopment | Test First Design
TDD - Test Driven Dvelopment | Test First DesignQuang Nguyễn Bá
 
Scrum sử dụng Team Foundation Server 2012
Scrum sử dụng Team Foundation Server 2012Scrum sử dụng Team Foundation Server 2012
Scrum sử dụng Team Foundation Server 2012Quang Nguyễn Bá
 
Introduction to Microsoft SQL Server 2008 R2 Integration Services
Introduction to Microsoft SQL Server 2008 R2 Integration ServicesIntroduction to Microsoft SQL Server 2008 R2 Integration Services
Introduction to Microsoft SQL Server 2008 R2 Integration ServicesQuang Nguyễn Bá
 
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2Introduction to Business Intelligence in Microsoft SQL Server 2008 R2
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2Quang Nguyễn Bá
 
Introduction to Microsoft SQL Server 2008 R2 Analysis Service
Introduction to Microsoft SQL Server 2008 R2 Analysis ServiceIntroduction to Microsoft SQL Server 2008 R2 Analysis Service
Introduction to Microsoft SQL Server 2008 R2 Analysis ServiceQuang Nguyễn Bá
 
SharePoint 2010 Business Intelligence
SharePoint 2010 Business IntelligenceSharePoint 2010 Business Intelligence
SharePoint 2010 Business IntelligenceQuang Nguyễn Bá
 
Programming SharePoint 2010 with Visual Studio 2010
Programming SharePoint 2010 with Visual Studio 2010Programming SharePoint 2010 with Visual Studio 2010
Programming SharePoint 2010 with Visual Studio 2010Quang Nguyễn Bá
 
SharePoint Web part programming
SharePoint Web part programmingSharePoint Web part programming
SharePoint Web part programmingQuang Nguyễn Bá
 

More from Quang Nguyễn Bá (19)

Lesson 08 Documents and Printings in WPF
Lesson 08 Documents and Printings in WPFLesson 08 Documents and Printings in WPF
Lesson 08 Documents and Printings in WPF
 
Lesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPFLesson 07 Actions and Commands in WPF
Lesson 07 Actions and Commands in WPF
 
Lesson 04 WPF Controls
Lesson 04 WPF ControlsLesson 04 WPF Controls
Lesson 04 WPF Controls
 
Lesson 03 Layouts in WPF
Lesson 03 Layouts in WPFLesson 03 Layouts in WPF
Lesson 03 Layouts in WPF
 
Lesson 02 Introduction to XAML
Lesson 02 Introduction to XAMLLesson 02 Introduction to XAML
Lesson 02 Introduction to XAML
 
Lesson 01 Introduction to WPF
Lesson 01 Introduction to WPFLesson 01 Introduction to WPF
Lesson 01 Introduction to WPF
 
Business intelligence
Business intelligenceBusiness intelligence
Business intelligence
 
TDD - Test Driven Dvelopment | Test First Design
TDD -  Test Driven Dvelopment | Test First DesignTDD -  Test Driven Dvelopment | Test First Design
TDD - Test Driven Dvelopment | Test First Design
 
Scrum sử dụng Team Foundation Server 2012
Scrum sử dụng Team Foundation Server 2012Scrum sử dụng Team Foundation Server 2012
Scrum sử dụng Team Foundation Server 2012
 
Introduction to Microsoft SQL Server 2008 R2 Integration Services
Introduction to Microsoft SQL Server 2008 R2 Integration ServicesIntroduction to Microsoft SQL Server 2008 R2 Integration Services
Introduction to Microsoft SQL Server 2008 R2 Integration Services
 
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2Introduction to Business Intelligence in Microsoft SQL Server 2008 R2
Introduction to Business Intelligence in Microsoft SQL Server 2008 R2
 
Introduction to Microsoft SQL Server 2008 R2 Analysis Service
Introduction to Microsoft SQL Server 2008 R2 Analysis ServiceIntroduction to Microsoft SQL Server 2008 R2 Analysis Service
Introduction to Microsoft SQL Server 2008 R2 Analysis Service
 
Office 2010 Programming
Office 2010 ProgrammingOffice 2010 Programming
Office 2010 Programming
 
Giới thiệu WCF
Giới thiệu WCFGiới thiệu WCF
Giới thiệu WCF
 
MOSS 2007 Overview
MOSS 2007 OverviewMOSS 2007 Overview
MOSS 2007 Overview
 
SharePoint Programming Basic
SharePoint Programming BasicSharePoint Programming Basic
SharePoint Programming Basic
 
SharePoint 2010 Business Intelligence
SharePoint 2010 Business IntelligenceSharePoint 2010 Business Intelligence
SharePoint 2010 Business Intelligence
 
Programming SharePoint 2010 with Visual Studio 2010
Programming SharePoint 2010 with Visual Studio 2010Programming SharePoint 2010 with Visual Studio 2010
Programming SharePoint 2010 with Visual Studio 2010
 
SharePoint Web part programming
SharePoint Web part programmingSharePoint Web part programming
SharePoint Web part programming
 

Recently uploaded

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 

Recently uploaded (20)

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 

Lesson 05 Data Binding in WPF

  • 1.
  • 2. Data binding is the mechanism by which information contained in an object is associated with elements in your user interface Data binding is the process that establishes a connection between the application UI and business logic
  • 3.  data binding is about keeping object properties and collections of objects synchronized with one or more controls’ views of the data  The goal of data binding  Save the time required to write the code to: ▪ Update controls when the data in the objects changes ▪ Update data when user edits the data in the controls  The synchronization of the data to the controls depends on the INotifyPropertyChanged and INotifyCollectionChanged interfaces
  • 4.  Example  Target Object =TextBlock  Dependency Property =Text  Source Object = Person  Property = Name <Grid Name="grid" DataContext="{StaticResource Person}"> … <TextBlockText="{Binding Path=Name}" /> </Grid>
  • 5.  OneWay: Source changed Target change  TwoWay: Source change Target change  OneWayToSource:Target changed  Source change
  • 7.  ValueConverter used to bind two properties of different types together.  ValueConverter converts the value from a source type to a target type and back.  Implementing the IValueConverter interface to create your own ValueConverter <Button Background="{Binding Source={StaticResource myDataSource}, Path=ColorName}">I am bound to be RED!</Button>
  • 8.  We would need to create a custom converter by implementing the IValueConverter interface
  • 9.  Collection Object must implement the INotifyCollectionChanged interface  Each object in collection must also implement the INotifyPropertyChanged interface
  • 11.  CollectionViews are used to sort, filter, or group the data when ItemsControl is bounded to a data collection  CollectionViews are classes that implement the ICollectionView interface  Each source collection can have multiple views associated with it  Same data can display in different ways
  • 12. Name Type Descriptions MoveCurrentToFirst Method Sets the first item in the view as the CurrentItem. MoveCurrentToLast Method Sets the last item in the view as the CurrentItem. MoveCurrentToNext Method Sets the item after the CurrentItem in the view as the CurrentItem. MoveCurrentToPrevious Method Sets the item before the CurrentItem in the view as the CurrentItem. CurrentItem Properties Gets the current item in the view. Filter Properties Gets or sets a method used to determine if an item is suitable for inclusion in the view. Groups Properties Gets a collection of the top-level groups that is constructed based in the GroupDescriptions property. SortDescriptions Properties Gets a collection of SortDescription structures that describes how the items in the collection are sorted in the view.
  • 14.
  • 15.  DataTemplates allow you to define compelling visuals for your data.
  • 16.  TheWPF data binding model allows associate ValidationRules with your Binding object
  • 17.  The ValidationRules property takes a collection of ValidationRule objects  There are some built-in ValidationRule in WPF ▪ ExceptionValidationRule checks for exceptions thrown during the update of the binding source property. ▪ DataErrorValidationRule object checks for errors that are raised by objects that implement the IDataErrorInfo interface.  Your own validation rule must deriving from the ValidationRule class and implementing the Validate method
  • 18.
  • 20.  Object Data Provider  Derived from the DataSourceProvider  Using object as Data Context  Binding by Path property  XML Data Source Provider  Derived from the DataSourceProvider  Using XML data as Data Context  Binding by XPath property

Editor's Notes

  1. As illustrated by the above figure, data binding is essentially the bridge between your binding target and your binding source. The figure demonstrates the following fundamental WPF data binding concepts: Typically, each binding has these four components: a binding target object, a target property, a binding source, and a path to the value in the binding source to use. For example, if you want to bind the content of a TextBox to the Name property of an Employee object, your target object is the TextBox, the target property is the Text property, the value to use is Name, and the source object is the Employee object. The target property must be a dependency property. Most UIElement properties are dependency properties and most dependency properties, except read-only ones, support data binding by default. (Only DependencyObject types can define dependency properties and all UIElements derive from DependencyObject.) Although not specified in the figure, it should be noted that the binding source object is not restricted to being a custom CLR object. WPF data binding supports data in the form of CLR objects and XML. To provide some examples, your binding source may be a UIElement, any list object, a CLR object that is associated with ADO.NET data or Web Services, or an XmlNode that contains your XML data. For more information, see Binding Sources Overview.
  2. Not illustrated in the figure is OneTime binding, which causes the source property to initialize the target property, but subsequent changes do not propagate. This means that if the data context undergoes a change or the object in the data context changes, then the change is not reflected in the target property. This type of binding is appropriate if you are using data where either a snapshot of the current state is appropriate to use or the data is truly static. This type of binding is also useful if you want to initialize your target property with some value from a source property and the data context is not known in advance. This is essentially a simpler form of OneWay binding that provides better performance in cases where the source value does not change.
  3. How to Implement Collections You can enumerate over any collection that implements the IEnumerable interface. However, to set up dynamic bindings so that insertions or deletions in the collection update the UI automatically, the collection must implement the INotifyCollectionChanged interface. This interface exposes an event that should be raised whenever the underlying collection changes. WPF provides the ObservableCollection<(Of <(T>)>) class, which is a built-in implementation of a data collection that exposes the INotifyCollectionChanged interface. Note that to fully support transferring data values from source objects to targets, each object in your collection that supports bindable properties must also implement the INotifyPropertyChanged interface. For an example, see Binding to a Collection Sample. For more information, see Binding Sources Overview.
  4. Most applications that take user input need to have validation logic to ensure that the user has entered the expected information. The validation checks can be based on type, range, format, or other application-specific requirements.