简体   繁体   中英

Can I use 2 App.XAML in one silverlight project?

Can I use 2 App.XAML in one silverlight project?

If answer is Yes. How can I select from that use in Application use? If No. Can you explain the reason?

To naively answer the question you've appear to have asked; the answer is no you can't. Ultimately the application manifest must specify a single assembly and type that is derives from Application .

However here is my guess at what you really want to achieve. You don't want to have to define all the application resources in a single App.xaml file.

You can divide up resources into separate resource dictionary files. Use the "Add New Item..." on the project and select the "Silverlight Resource Dictionary". Create two or more of these and divide up the resources currently in App.xaml into these new files in a logical fashion. For sake of example lets say you have a "Colors.xaml" and a "CommonStyles.xaml".

Now you use the MergedDictionaries property to list these resource dictionaries to aggregate them into your App.Xaml. Ideally your App.xaml just ends up looking like this:-

<Application.Resources>
  <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
      <ResourceDictionary Source="Colors.xaml" />
      <ResourceDictionary Source="CommonStyles.xaml" />
    </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</Application.Resources>

您可以在Silverlight项目中拥有多个“应用程序”,只需在“启动”对象下的“项目属性”表中选择所需的一个。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM