Introducing XCC, an open source preprocessor adding conditional compilation support to XAML files. Enable XCC in your project by installing a tiny (only 10KB!) NuGet package.
XCC uses custom XML namespaces for defining conditions. When an XML element or attribute is in a custom condition namespace, it is included or excluded based on the compilation symbols. XCC includes a MSBuild task that preprocesses the XAML just before handing it over to the XAML compiler.
The following XAML snippet is just an example of how XCC can simplify your XAML files.
<Page ... xmlns:debug="condition:DEBUG" xmlns:release="condition:!DEBUG"> <StackPanel> <debug:TextBlock Text="I'm only available in DEBUG" /> <release:TextBlock Text="I'm only available in RELEASE" /> <TextBlock Text="I'm always available" debug:Foreground="Red" /> </StackPanel> </Page>
XCC works great with XAML files in shared universal app projects for Windows 8.1 and Windows Phone 8.1.
Learn more about XCC at xcc.codeplex.com