Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does WPF databinding make things more of a pain than it is worth?

Ok, So I have been stalled in my latest non-work project, trying to use WPF. I am just frankly annoyed at databinding. I thought it was supposed to make things simpler by binding data directly to the UI. But the more I learn about having to implement INotifyPropertyChanged to get things to notify the UI if they changed, seems to make the whole thing counter productive.

Am I missing something? It seems like a bunch of work and having to make the classes implemented INotifyPropertyChanged seems like a fishy way to get databinding to work.

What am I missing? I must be missing something. Please enlighten me into how to make databinding easy, or at the least straightforward.

like image 747
Alex Baranosky Avatar asked Feb 20 '09 21:02

Alex Baranosky


People also ask

What does binding DO WPF?

Data binding in Windows Presentation Foundation (WPF) provides a simple and consistent way for apps to present and interact with data. Elements can be bound to data from different kinds of data sources in the form of . NET objects and XML.

How does XAML binding work?

Data binding is a mechanism in XAML applications that provides a simple and easy way for Windows Runtime Apps using partial classes to display and interact with data. The management of data is entirely separated from the way the data is displayed in this mechanism.

What is it data binding?

Data binding is the process that couples two data sources together and synchronizes them. With data binding, a change to an element in a data set automatically updates in the bound data set.


1 Answers

If you want the UI be notified when the underlying data source changes, then you need some sort of notification mechanism. For WPF, INotifyPropertyChanged is that mechanism.

It's the same in Windows Forms as well, but Windows Forms also supports the old notification mechanism, where you have an event with the name <Property>Changed.

However, neither of these required these mechanisms if all you want to do is bind to the data once and display it.

If you are ok with not receiving notifications, then just bind to the data source and it will work.

like image 128
casperOne Avatar answered Nov 15 '22 07:11

casperOne