locked
Dynamic registration of Document templates RRS feed

  • Question

  •  

    Hi,

     

    I try to register dynamically some document templates.

    How can i do. I cannot access to the DocumentTemplates property within code-behind.

     

    Thanks.

     

    Monday, August 27, 2007 11:54 AM

Answers

  • Finally a found a simple solution.

    you must first declare the DocumentManager in the xaml side :

    Code Snippet

    <AcropolisApplication.LifetimeManager>

    <Afx:DocumentManager x:Name="DocumentManager" />

    </AcropolisApplication.LifetimeManager>



    and the, in the code-behind :

    Code Snippet

    Type partType = Type.GetType("MyNamespace.MyPart, MyAssembly");
    DocumentTemplate documentTemplate = new DocumentTemplate(".txt", partType);
    this.DocumentManager.Templates.Add(documentTemplate);  

           

    That's all folks !
    Wednesday, August 29, 2007 9:00 PM