cristina2sabre/CoAppPackageMaker24 — pull request #1 by ericschultz (2012-07-10 00:41:17+00:00)
Title: Added the focus behavior

ExtraPropertiesViewModel now includes a integer property called UndoCounter that is used as a dummy property. It's mainly used to notify the View that the change that occurred is actually an undo. A usercontrol in the view binds the UndoOccurredInt attached property to UndoCounter. When UndoOccurredInt changes, it fires a RoutedEvent called UndoOccurred which bubbles up the VisualTree. Each TabItem must have the FocusReceiveBehavior added which listens for the UndoOccurred event and when receiving it, sets IsSelected for that TabItem to true.

Note: This change requires the Blend SDK package which should be available for install via "CoApp install microsoft.blend*" or by going to http://coapp.org/packages and installing from there.

Summary of actual control flow:
1. A view model receives the UndoHappened event from the MonitoredUndo framework and then increments the UndoCounter property.
2. A UiElement in the View who has its UndoOccurredInt attached property bound to UndoCounter is notified of the property change and fires the UndoOccurred attached routed event.
3. The UndoOccurred bubbles up the visual tree.
4. When the UndoOccurred reaches a TabItem who has the FocusReceiveBehavior set, the TabItem's IsSelected property is set to true.
5. The UndoOccurred event keeps bubbling up the tree and will be caught by further TabItems with the FocusReceivedBehavior set ahd/or will get to the root of the tree and stop.