tags:

views:

221

answers:

2

Hi, 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,

A: 

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 (or VisualTreeHelper) to recurse through the WPF trees and find the controls you're interested in.

HTH, Kent

Kent Boogaart
A: 

Hi,

The reason I used this method is because I needed that information for other purposes, plus I was able to 'configured' that method to suit different needs. Frankly, I don't know what you mean by the view model. I am faily new in WPF so if it's something in it, then I doubt I ever heard of it before.

David Brunelle
I see. I'd suggest you read up on the MVVM pattern. This is a good article to get you started: http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
Kent Boogaart