我正在写一些 multi-targeting 应用程序(.net 4.0) . 我有ResourceDictionay的问题 . Scenario: 创建WPF CustomControlLibrary - 将其命名为"WpfLib",默认命名空间"test"在WpfLib中创建UserControl - 将其命名为"uc"

<UserControl x:Class="test.uc"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="res.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>   
    <Grid>
        <Button Style="{StaticResource bStyle}" Content="Button" Height="23"  Width="75" />
    </Grid>
</UserControl>

“res.xaml”的代码

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="bStyle" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="Red" /> 
    </Style>
</ResourceDictionary>

现在一切都很棒......按钮是红色的

现在让我们添加新的Project Silverlight应用程序并将其命名为“SlApp”(Silverlight 5)(命名空间“test”)让我们从“WpfLib”中添加“uc”作为链接(“uc.xaml”“uc.xaml.cs”) . 在“SlApp”中创建新的ResourceDictionary并将其命名为res.xaml,如下所示:

<ResourceDictionary
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Style x:Key="bStyle" TargetType="Button">
            <Setter Property="Background" Value="Blue" />
        </Style>
    </ResourceDictionary>

新的ResourceDictionary具有TargetType =“Button”,因为SilverLight不支持x:Type . 背景设置为蓝色而不是红色 .

这里开始出现问题 .
我如何使它工作?控制uc在合并时显示错误(在Silverlight版本中) . 我需要在Wpf和Silverlight版本的usercontrol上使用不同的ResourceDictionary . ClassLibrary没有't support app.xaml and i can' t使用默认样式 .