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,621   
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)
13 FEB
ASP.NET Core Development (online)

07:00 AM-09:00 AM IST( MON, WED, FRI)

Know More
25 JAN
Angular2 and Angular1 Development (online)

09:00 PM-10:30 PM IST(MON-FRI)

Know More
24 JAN
ASP.NET MVC with Angular2 Development (online)

07:00 AM-09:00 AM IST(Tuesday & Thursday)

Know More
21 JAN
Xamarin Forms : Build Cross-platform Apps (offline)

05:00 PM-06:30 PM IST

Know More
20 JAN
NODEJS & MEAN Stack 2 Development (online)

09:00 PM-11:00 PM IST( MON, WED, FRI)

15 JAN
PPC Marketing (offline)

04:00 PM-05:300 PM

10 JAN
ASP.NET MVC with AngularJS Development (online)

09:00 PM-11:00 PM IST on (TUE, THRU,SAT)

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

07:00 AM-09:00 AM IST

31 DEC
ASP.NET MVC with AngularJS Development (offline)

09:30 AM-11:00 AM

31 DEC
Angular2 and Angular1 Development (offline)

11:00 AM-12:30 AM

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

03:00 PM-04:30 PM

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

08:00 AM-09:30 AM

4 SEP
MEAN Stack 2 Development (offline)

11:00 AM-12:30 PM.

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

Professional Speaks

+