I have a XAML file that I exported from Expression Design. I would like to render that XAML content inline in one of my user controls. Can I reference the external XAML file that I want to include as a Resource on the UserControl I want to render it in? Or is there some other markup that I can use to identify the XAML object in my project that I want rendered in the current location?
I am using Silverlight 4.
You can include the XAML as content or as a file on the web server and use XamlReader.Load to dynamically load and create Xaml content. There’s not a control that can do what you want directly (but it would be simple to wrap the functionality described in the link).
For example:
Then, using whatever your favorite trick is for loading Content, get the above string and Load it:
Then, add the canvas as a child to the parent control (or whatever the type is you want to use, as it doesn’t need to be a Canvas).
My Xaml in the above case was in a file marked as “Content” and used a XDocument to load it based on an ID (My XML document has multiple free floating assets all tagged with an ID):