title: Set controls on wpf form to readonly or editable
body: <p>I am writing a data entry application and am having problems dealing with add vs edit vs view 'modes' of the app.  </p>
  
  <p>The scenario:  From a window, the user selects items in two combo boxes and then clicks a button.  If the combo box selections don't match an existing record, the form should open with a new record ready to have values inserted.  If the selections DO match an existing record, this record should be opened with all the textboxes in the form in 'Readonly' mode.  Should the user wish to modify the existing data, they click the form's Edit button which sets the textboxes as 'Editable'.</p>
  
  <p>I'm new to wpf, but in my vba apps, I'd normally have a DataMode property and a ToggleControls method which would loop through the TabControl's TabItems and then loop through the TabItems' controls, setting the IsReadOnly property of any TextBox controls found based on the 'DataMode' property.  However, I have doubts about whether this is the path to follow in wpf.</p>
  
  <p>So, my question is, do i use the approach above?  If so, how do I access the controls in a TabItem.  This doesn't work: <code>foreach (Control ctrl in MyTabCtrl) { //if Textbox do stuff }</code>.</p>
  
  <p>If this isn't the way to do it, can someone show me the way?  I'm guessing it's either a template / style issue or something to do with setting the data as readonly somehow, and then binding the TextBox's IsReadOnly property to the state of the data. Edit: Oh, or that ViewStateManager thing.  All of which i know little about. </p>