protected override void Dispose(bool disposing)
{
if (disposing) {
// Walk the visual tree looking for disposable elements.
if (_hwndSource != null) {
UIElement root = _hwndSource.RootVisual as UIElement;
if (root != null) {
root.DisposeSubTree();
}
_hwndSource.Dispose();
_hwndSource = null;
}
}
base.Dispose(disposing);
}