新建一个名为"Dictionary1"的资源字典:<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="aa">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border Background="Red">
                        <ContentPresenter />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
在项目中使用:<Window x:Class="WPF3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="800" Width="1105">
    <Window.Resources>
        <Style x:Key="bb">
            <Setter Property="Control.Template" >
                <Setter.Value>
                    <ControlTemplate>
                        <Grid>
                            <Control Style="{DynamicResource aa}">
                                <Control.Resources>
                                   <ResourceDictionary Source="pack://application:,,,/WPF3;component/Dictionary1.xaml"/> 
                                </Control.Resources>
                            </Control>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
</Window>第二段代码为什么会出现这样的错误:无法将类型为“System.Windows.ResourceDictionary”的对象强制转换为类型“Microsoft.Expression.Markup.DocumentModel.DocumentCompositeNode”