views:

35

answers:

1

Hello!

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.

+1  A: 

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.

Pete OHanlon
Thank you Pete, The class is really simple, but I want to learn how to do this thing for every situation.On the other hand, I don't know what do you mean with the late bind thing, but I will do some research first on that subject.
Jesus Rodriguez
That's a great attitude Jesus. Good reply.
Pete OHanlon