0

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?

4
  • 1
    Why would you want to do that? Commented Nov 12, 2013 at 0:14
  • Do you mean like a MergedDictionary ? Commented Nov 12, 2013 at 0: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? Commented Nov 12, 2013 at 0:19
  • Does the order matter or you want the elements to be combined? Commented Nov 12, 2013 at 0:42

3 Answers 3

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>
Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

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.

1 Comment

I would suggest you to adding some link to documentation on user controls in WPF, so OP can do some reading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.