Having looked at several tutorials I can't help but think data binding seems unnecessarily complicated...

Let's say I want a label to show whether a user is logged in or not. The obvious way to me is in the login code put something like: lb_LoggedIn.Content = User + " Logged In"; and then in the logout code put: lb_LoggedIn.Content = "Please Login"; and maybe add a link or something.

I don't get why you would do all the complexity of adding dependency properties and bindings and stuff here? Would it be useful if there was more than one way to login or logout?

Or alternatively, I want to display a list of names pulled from a web xml file. So they're not known at design time & once the program is running they won't be changed again. So again, I could databind a listview to an arraylist or something, but isn't it simpler just to add them to the listview one by one as they're first read from the XML?

I feel like I must be missing something fundamental here! If anyone can point me to a simple example of binding a control to a single property that would be great, most of the tutorials show binding one control to another or binding to a list of info hardcoded into the XAML which both seem completely pointless.

Recommended Answers

All 2 Replies

I can't help but think data binding seems unnecessarily complicated...

Implement equivalent behavior manually a few times and you'll begin to see how data binding makes life simpler. Of course, there's quite a learning curve in my experience, because binding can create frustratingly difficult to fix bugs. But once you get a handle on it, I think binding is worth it.

isn't it simpler just to add them to the listview one by one as they're first read from the XML?

If it's just a matter of displaying read-only content, probably. But data binding also maintains updates to the underlying data. When you need to keep track of insertions, deletions, and data changes in existing records, the maintenance code grows significantly both in size and complexity.

Thanks - the latter example of XML/listview is just a read only list so I guess I'll stick with what I'm doing for this.

The frustrating part is I totally get the idea of data binding, separating design from the code and allowing it all to update automatically, it all sounds great. Then I look at how to do it and get bogged down in terminology or examples which don't seem applicable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.