Jesus Rodriguez
Jesus Rodriguez

Reputation: 12018

Using databinding whenever I can?

I have a Question:

Should I use databinding whenever I can?

I will explain myself.

I have a class instantiated on the Main Windows ViewModel, I have this class istantiated because I have a section on the window that will use it.

The problem is that section on the window will be used very few times, then, I have a class instantiated always and maybe in that execution, I will not use it.

That section has 2 textbox that are binded to 2 propertys on that class instance, and a button that process the information on that class.

The question is again: Should I have that class instantiated every time or should I get the text of the textbox by hand and create an instance?

Thank you.

Upvotes: 0

Views: 55

Answers (1)

Pete OHanlon
Pete OHanlon

Reputation: 9146

The overhead of having the class instantiated is probably going to be very low. I say probably because I don't know how much data you are going to have there. Whenever possible, you should use the binding mechanism in WPF because it removes a lot of issues that you would have as a developer remembering to update bits and pieces here and there.

It is possible that your VM could late bind these pieces of data based on an external event.

Upvotes: 1

Related Questions