2

我在 Windows Phone 项目中得到了 generic.xaml 文件,它变得太大了。如何将 generic.xaml 划分为多个文件?

我知道<ResourceDictionary.MergedDictionaries>但是,我不能让它工作。项目编译,但是当 Page 尝试解析 xaml 资源时出现运行时异常。

我试过了:

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="WatermarkedPinBox.xaml"/>
</ResourceDictionary.MergedDictionaries>

请帮帮我,我不喜欢大资源文件。很难使它们的结构保持良好状态。

4

1 回答 1

-1

您可以使用MergedDictionaries拆分Generic.xaml文件。看看这个例子:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mscorlib="clr-namespace:System;assembly=mscorlib">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/YourProjectName;component/Themes/YourSecondResourceFileName.xaml" />
        <ResourceDictionary Source="/YourProjectName;component/Themes/YourThirdResourceFileName.xaml" />
    </ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

Build Action对于 YourSecondResourceFileName.xaml 和 YourThirdResourceFileName.xaml 必须设置为Page.

于 2013-06-10T17:42:17.013 回答