Home » Visual Studio

Problem with xmlmapping and dynamic content controls


I'm trying to add controls dynamically with the help of document fragments in VSTO 2010. Short version (where frag.docx contains a content control with the tag "tag1"):


string xPathName = "ns:employees/ns:employee[2]/ns:name";
Globals.ThisDocument.SelectContentControlsByTag("tag1")[1].XMLMapping.SetMapping(xPathName, ThisDocument.prefix, Globals.ThisDocument.employeeXMLPart);

Complete code can be found here: http://www.mediafire.com/?3505iovi814ez7w

This was adapted from the code posted here: http://msdn.microsoft.com/en-us/library/bb398244.aspx

The first problem is that the custom xml part doesn't seem to be updated when I change the data of the custom controls. E.g. change the name of an employee.

The second problem is that the title dropdown list isn't populated with it's proper values from the schema.

What have I missed? Is there a better way of doing this?

<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure