Please enable Javascript to correctly display the contents on Dot Net Tricks!

OneTime, OneWay and TwoWay Binding for Windows Phone

  Author : Shailendra Chauhan
Updated On : 26 Sep 2016
Total Views : 4,523   
Support : Windows Phone 8 & 7.1
 

Most Windows Phone apps display data to user by using controls, from business object or a collection of business objects such as a list of contact numbers, news headlines, or images. These controls contain data by using data binding. In this article, I would like to share the different types of data binding for windows phone.

Types of Data Binding for Windows Phone

We have three types of data bonding for windows phone which determines how and when the data flows.

  1. OneTime Data Binding

    This binding mode update the dependent target control's property with the source object property only one time when the binding is created mean when your phone app starts or when you set DataContext property. This type of mode can be used when you want to display data for first time only.

    <TextBlock Text="{Binding ID, Mode=OneTime}" />
    
  2. OneWay Data Binding

    This binding mode update the dependent target control's property with the source object property when the binding is created and anytime the source object property changes. This is the default binding for any control. In this binding mode target control's property updated only when source property changed.

    <TextBlock Text="{Binding ID, Mode=OneWay}" />
    <TextBox Text="{Binding Name, Mode=OneWay}" />
    
  3. TwoWay Data Binding

    This binding mode update both the dependent target control's property and the source object property when either changes, It means when source object property changed it will update target control's property and when target control's property changed will update source object property.

    <TextBox Text="{Binding Name, Mode=TwoWay}" />
    

Note

  1. For OneWay and TwoWay binding, the source object must implement the INotifyPropertyChanged interface.

  2. Use OneTime binding when you want to display data for first time only. It usually used with TextBlock.

  3. Use OneWay binding when you want to display changed source data each time. It usually used with TextBlock.

  4. Use TwoWay binding when you want to persist change occurs either of source or target property. It usually used with TextBox.

What do you think?

I hope you will enjoy the tips while binding data to your windows phone app controls. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

YOU MIGHT LIKE
Free Interview Books
 
COMMENTS (0)
14 DEC
ASP.NET MVC with AngularJS Development (online)

MON-FRI 07:30 AM- 09:00 AM IST

Know More
5 DEC
AngularJS Development (online)

Mon - Fri     6:30 AM-7:30 AM IST

3 DEC
AngularJS Development (offline)

SAT,SUN     11:00 AM-12:30 PM IST

3 DEC
MEAN Stack Development (offline)

Sat, Sun     (09:30 AM-11:00 AM IST)

26 NOV
ASP.NET MVC with AngularJS Development (offline)

(SAT,SUN)     03:30 PM-05:00 PM IST

24 NOV
ASP.NET MVC with AngularJS Development (online)

MON-FRI     09:30 PM-11:00 PM IST

12 NOV
ASP.NET MVC with AngularJS Development (offline)

SAT,SUN     08:00 AM-09:30 AM

3 NOV
ASP.NET MVC with AngularJS Development (online)

MON-FRI     07:30 AM-09:00 AM IST

25 OCT
.NET Development (offline)

Mon-Fri     9:00 AM-11:00 AM IST

BROWSE BY CATEGORY
 
RECENT ARTICLES
SUBSCRIBE TO LATEST NEWS
 
LIKE US ON FACEBOOK
 

Professional Speaks

+