Input And Data Binding in WPF Development - PowerPoint PPT Presentation

About This Presentation
Title:

Input And Data Binding in WPF Development

Description:

Windows Presentation Foundation (WPF) provides a powerful API with the help of which applications can get input from various devices such as mouse, keyboard, and touch panels. Data binding is the process that establishes a connection between the application UI and business logic. – PowerPoint PPT presentation

Number of Views:47

less

Transcript and Presenter's Notes

Title: Input And Data Binding in WPF Development


1
iFour Consultancy
https//www.ifourtechnolab.com/wpf-software-develo
pment
2
Input And Data Binding
  • Windows Presentation Foundation (WPF) provides a
    powerful API with the help of which applications
    can get input from various devices such as mouse,
    keyboard, and touch panels.
  • Data binding is the process that establishes a
    connection between the application UI and
    business logic. If the binding has the correct
    settings and the data provides the proper
    notifications, then, when the data changes its
    value, the elements that are bound to the data
    reflect changes automatically

https//www.ifourtechnolab.com/wpf-software-develo
pment
3
What We Will Cover
  • Binding data to UI Elements
  • Using Converters to convert data during Binding
  • Using Data Templates to visualize data

https//www.ifourtechnolab.com/wpf-software-develo
pment
4
Data Binding Concepts
  • Binding Components
  • Target Object
  • Target Property
  • Binding Source
  • Path
  • Target Property Must be a dependency property

https//www.ifourtechnolab.com/wpf-software-develo
pment
5
Binding Modes
  • OneWay-Updates the target property only when the
    source property change.
  • TwoWay-Updates the target property or the
    property whenever either the target property or
    the source property changes.
  • OneWayToSource-updates the source property when
    the target property changes
  • OneTime- Updates the target property only when
    the application starts or when the DataContext
    undergoes a change.

https//www.ifourtechnolab.com/wpf-software-develo
pment
6
What Triggers Updates
  • Triggering supported by TwoWay or OneWayToSource
    mode of binding
  • Dependency property or INotifyPropertyChanged
  • UpdateSourceTrigger property
  • Explicit -Updates the binding source only when
    you call.
  • UpdateSource- method. 
  • LostFocus-Updates the binding source whenever the
    binding target element loses

https//www.ifourtechnolab.com/wpf-software-develo
pment
7
Data Binding Methods
  • Binding using XAML
  • Binding using Code

ltLabel Name"lblNote" Content"DynamicResource
ResourceKeyNote" /gt ltTextBox Name"txtNote"
VerticalContentAlignment"Top"
HorizontalAlignment"Stretch" Text"Binding
AppointmentNote,ModeTwoWay" VerticalAlignment"S
tretch" Width"Auto" Height"Auto" /gt
MyData myDataObject new MyData(DateTime.Now)
Binding myBinding new
Binding("MyDataProperty") myBinding.Source
myDataObject myText.SetBinding(TextBlock.TextPr
operty, myBinding)
https//www.ifourtechnolab.com/wpf-software-develo
pment
8
Converting DataOverview
  • Used when data doesnt match between bindings
    create a conversion class
  • When to use
  • Culture changes needed
  • Different View of data then native storage
  • Incompatible data types between target and source

https//www.ifourtechnolab.com/wpf-software-develo
pment
9
Converting Data Out-of-Box Converters
  • Contained in the System.Windows.Controls
    namespace
  • BooleanToVisibilityConverter
  • Converts True/False to Visible, Hidden or
    Collapsed
  • BorderGapMaskConverter
  • Represents a converter that converts the
    dimensions of a GroupBox control into a
    VisualBrush

https//www.ifourtechnolab.com/wpf-software-develo
pment
10
Data Templates Overview
  • Makes it easy to put content with data
  • Easy to define visual styles for data
  • Reusable and modifiable

https//www.ifourtechnolab.com/wpf-software-develo
pment
Write a Comment
User Comments (0)
About PowerShow.com