none
Is It Possible to Refer to SdtContent Generically RRS feed

  • Question

  • What I mean by this is, rather than specify SdtContentRun or SdtContentCell or SdtContentWhatever, is it possible to do something like GetFirstChild<GenericSdtContent>()? I have a pretty simple function that just inserts text into a content control, but it would be nice if I didn't have to check as to what kind of SdtContent it was.
    Thursday, July 8, 2010 9:44 PM

Answers

  • Hello MRH,

    As far as I know, the answer is no. Open XML SDK only provides strong typed classes for different kinds of content elements. And there is no generic SdtContent class that covers all of the SdtContent**. We have to call codes on different types of content separately,

    GetFirstChild<SdtContentCell>()

    GetFirstChild<SdtContentBibliography>()

    GetFirstChild<SdtContentBlock>()

    GetFirstChild<SdtContentDate>()

    ...

     


    Best regards,
    Ji Zhou - MSFT
    Microsoft Online Community Support

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by M_R_H Thursday, July 15, 2010 1:32 PM
    Thursday, July 15, 2010 10:19 AM
    Moderator

All replies

  • Hello MRH,

    As far as I know, the answer is no. Open XML SDK only provides strong typed classes for different kinds of content elements. And there is no generic SdtContent class that covers all of the SdtContent**. We have to call codes on different types of content separately,

    GetFirstChild<SdtContentCell>()

    GetFirstChild<SdtContentBibliography>()

    GetFirstChild<SdtContentBlock>()

    GetFirstChild<SdtContentDate>()

    ...

     


    Best regards,
    Ji Zhou - MSFT
    Microsoft Online Community Support

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by M_R_H Thursday, July 15, 2010 1:32 PM
    Thursday, July 15, 2010 10:19 AM
    Moderator
  • Thanks for the response, Ji.Zhou.
    Thursday, July 15, 2010 1:32 PM