Mefhisto1
Mefhisto1

Reputation: 2228

Merging mutiple XAML files into one

I'm trying to merge multiple xaml files into one file. I'm looking for advice on how to continue. Currently, I just append xaml code to one file, but without taking care of headers and footers (opening and closing ResourceDictionary tags, and namespace mappings).

<ResourceDictionary 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><SolidColorBrush x:Key="MyBrush">#FFE4F2F9</SolidColorBrush></ResourceDictionary>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib"> <some xaml code /> </ResourceDictionary>

The only thing that comes to my mind is using regular expressions to extract ResourceDictionary bodies and place them inside one ResourceDictionary tag. However, what would be the best course of action here, and also, caring not to duplicate namespace mappings (like System namespace mapping, that is referenced inside multiple files).

Upvotes: 0

Views: 412

Answers (1)

Rob van Daal
Rob van Daal

Reputation: 367

It sounds like you don't know how to use merged dictionaries. I think this will help you.

Upvotes: 1

Related Questions