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

OneTime, OneWay and TwoWay Binding for Windows Phone

  Author : Shailendra Chauhan
Posted On : 09 Mar 2013
Total Views : 4,880   
Updated On : 26 Sep 2016
 

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.



Free Interview Books
 
COMMENTS (0)
23 MAY
Xamarin Forms : Build Cross-platform Apps (Online)

09:00 PM-11:00 PM IST(+5.30 GMT)

Know More
5 MAY
ASP.NET MVC with Angular4 Development (Online)

06:30 AM-08:30 AM IST(+5.30 GMT)

Know More
29 APR
Xamarin Forms : Build Cross-platform Apps (Classroom)

5:00 PM-6:30 PM

Know More
29 APR
ASP.NET MVC with Angular2 Development (Classroom)

9:30 AM-11:00 AM

Know More
27 APR
ASP.NET Core Development (Online)

07:00 AM - 09:00 AM IST( TUS, THR)

Know More
22 APR
NodeJS Development (Classroom)

11:00 AM-12:30 PM

10 APR
Master Class ASP.NET MVC 5 with Angular2 Plus Angular4 Development (Online)

09:00 PM - 11:00 PM IST (M/W/F)

8 APR
MEAN Stack 2 Development (Classroom)

11:00 AM-12:30 PM

25 MAR
Xamarin Forms : Build Cross-platform Apps (Classroom)

8:00 AM-9:30AM

21 MAR
ASP.NET MVC with Angular2 Development (Online)

09:00 PM - 11:00 PM IST( TUS, THR, SAT)

25 FEB
ASP.NET MVC with Angular2 Development (Classroom)

03:30 PM-05:30 PM

24 FEB
Angular 2 with Type Script (Online)

09:00 PM-11:00 PM IST(Mon,Wed,Fri)

BROWSE BY CATEGORY
 
 
LIKE US ON FACEBOOK
 
+