I'm trying to combine multiple XAML files to make a big XAML file with different elements, how can I make that happen if I have like 10 XAML single files?
Asked
Active
Viewed 1,630 times
0
-
1Why would you want to do that? – Arian Motamedi Nov 12 '13 at 00:14
-
Do you mean like a [MergedDictionary](http://msdn.microsoft.com/en-us/library/aa350178%28v=vs.110%29.aspx) ? – clcto Nov 12 '13 at 00:15
-
please clarify your question ... Is it data you're reading? otherwise, like @clcto said, are you looking at merging dictionaries? are you looking to have a program that copies several xmls into one? – Noctis Nov 12 '13 at 00:19
-
Does the order matter or you want the *elements* to be combined? – Alireza Noori Nov 12 '13 at 00:42
3 Answers
2
Create a ResourceDictionary. You can then use the ResourceDictionary.MergedDictionaries tag.
<Application.Resources>
<ResourceDictionary>
<SolidColorBrush Color="#d0157820" x:Key="muddyBrush"/>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="firstXamlFile.xaml" />
<ResourceDictionary Source="secondXamlFile.xaml" />
<ResourceDictionary Source="anotherXamlFile.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

nickm
- 1,775
- 1
- 12
- 14
2
You can merge multiple XAML file using merge distionary in App.XAML file. this will apply on all controls of the application.
like..
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="your1stXamlFile.xaml" />
<ResourceDictionary Source="Youe2ndXAMLFile.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

J R B
- 2,069
- 4
- 17
- 32
0
Sounds like you might want to use UserControls? E.g. you have several user controls that are just used and displayed in the main window.

Jacquers
- 179
- 1
- 4
-
I would suggest you to adding some link to documentation on user controls in WPF, so OP can do some reading – Cleptus May 27 '20 at 08:34