I implemented a fonction in Visual Basic 2008 that takes the content of all the controls from a System.Winows.Form object and return a hash value corresponding to this content. The use of this function is to detect whether or not the user modified the content of the page and determine if I have to display a message box asking to save. I tried to do this in WPF but I can’t seem to get all the controls in the form.
Is there any way to do this, or better, is there a function that does what I need?
Thanks,
Sorry, but I think that’s a really awful way to detect changes. A much nicer way would be to simply track changes in your view model and expose a dirty flag.
That said, you can use
LogicalTreeHelper(orVisualTreeHelper) to recurse through the WPF trees and find the controls you’re interested in.