Only for those who copy this code, keep in mind that if there are no locks associated with the content control, then there will be no Lock property associated with it, therefore, when the code executes the following statement, it will throw an exception, since the element does not found:
Lock l = elem.SdtProperties.ChildElements.First<Lock>();
To fix this, do FirstOrDefault instead of First .
Hugo barona
source share