refactored common template code and added ImplementDependencyProperties
added DebuggerNonUserCode attribute