I need to do this in code, not XAML.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Its not possible to programmatically create the content of a data template in the same way you might create Controls and add them to a
UserControl.Instead you will need to use
System.Xml.Linq.XDocumentto construct the DataTemplate as XML withDataTemplatebeing the root element. Once complete you can retrieve the XML string for the Root element and then useXamlReader.Loadto get a constructedDataTemplate.