views:

23

answers:

1

Suppose I have a Window with TextBoxes I want to use the values. Right now I'm thinking of either:

1) Updating each associated value once the cursor is out of focus, and once the user presses Ok I start the program
2) Once the user presses Ok, I retrieve all the values at once then start the program

I'm not sure which one is better though. First alternative seems more modular, but there's more semantic coupling since I each new box is supposed to be updating its respective value.

I realize this isn't all that important, but I'm trying to understand when to centralize and when not to. Other better approachers are appreciated too.

+2  A: 

Use data binding to bind the text boxes' contents to objects in your code behind. WPF will take care of updating your attributes. Usually updating the data-bound value is done when the focus is lost on text boxes. However, you can also specify that it will happen whenever the value changes.

Joey