views:

367

answers:

1

I have a TreeView bound to an XmlDataProvider. The name of a node is reflected in the tree and the data of the node is in a TextBox. When you click on a tree item, it loads the data in the TextBox.

What is the best way to determine when a user has changed the source data referenced by the XmlDataProvider.

I would like to put an asterisk (*) next to the filename to say that the document is dirty and should be saved. This will also determine whether the user is reminded to save when the exit the program.

Unfortunately, when the TextBox is updated by the two-way binding, it fires the TextChanged event.

Is there a way to determine that the TextChanged event was fired by the two-way binding code instead of by the user?

I also tried to use the DataChanged event on the XmlDataProvider but this event only appears to fire when initially loading the data.

I suppose that I could trap the key presses in the TextBox directly but it seems messy.

[Edit] It appears that PreviewTextInput seems to work for this purpose...Is there a better way?

A: 

PreviewTextInput did the trick.

Timothy Lee Russell