If you are working with .NET 4, why not combine your two options and put XAML inside App.config ?
using System.Configuration; using System.Xaml; using System.Xml; public class XamlConfigurationSection : IConfigurationSectionHandler { public object Create(object parent, object configContext, XmlNode section) { return XamlServices.Parse(section.OuterXml); } }
This custom configuration section allows you to include any object described as XAML in App.config :
<configSections> <section name="SomeType" type="XamlConfigurationSection, …" /> </configSections> <SomeType xmlns="clr-namespace:SomeNamespace;assembly=…" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> … </SomeType>
provided that you have a type:
namespace SomeNamespace { public class SomeType { public SomeType() { … }
and finally get an instance of this type from App.config with:
var objectOfSomeType = ConfigurationManager.GetSection("SomeType") as SomeType;
stakx
source share