.Net Interview Questions and Answers

Search:

Explain the need of

By : Shiv Prasad Koirala | Feb 25th, 2014 | Views : 3635 | Comments : 0 Bookmark and Share

When we bind two WPF objects the target data is updated depending on the "UpdateSourceTrigger" events.


In case you are new to "UpdateSourceTrigger" please first read this before proceeding

http://dotnetinterviewquestion.wordpress.com/2013/12/18/how-does-updatesourcetrigger-affect-bindings-c-wpf-interview-questions-with-answers/

The "UpdateSourceTrigger" has events like lostfocus , property change etc. In other words when lostfocus or property change event happen on the target it makes a PULL to the source to get the latest data.



So it's very much possible that the WPF source data has changed and because the WPF target "UpdateSourceTrigger" event did not fire he did not make a pull and the data of the source is not in synch with the target. This is where "INotifyPropertyChanged" interface comes to use.


Below is a simple "clsCounter" class which has a "Counter" property and this property is incremented by "Increment" method.


Now if we bind WPF label or textbox to the "Counter" property and call the "Increment" method the new "Counter" value will not be propagated to the target. Because invoking a method does not trigger any "UpdateSourceTrigger" event.


So after calling the "Increment" method the "Counter" value of the source and the target are out of synch.


So create a push event from the source you need to first implement "INotifyPropertyChanged" interface as shown in the below figure. Now when someone calls the "Increment" method you can raise an event saying that the "Counter" property has changed by calling "PropertyChanged" function as shown in the below code.


In simple words the source sends a notification to the target WPF object that data has changed in the source and he should refresh himself with the fresh data.




Below is full "clsCounter" class code with "INotifyPropertyChanged" implemented.



www.questpond.com has great videos on WPF Interview preparation you can view the same from
http://www.questpond.com/demo.html


Below video explain what is WPF and how they differ from Windows form


 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
1 1 1 2 1
 
 
 
 

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

Article Categories

Learn in Hindi