C# 为什么';";资源字典“;工作

C# 为什么';";资源字典“;工作,c#,.net,wpf,xaml,resourcedictionary,C#,.net,Wpf,Xaml,Resourcedictionary,我的程序运行良好 <Window.Resources> <ResourceDictionary Source="GlassButton.xaml"> </ResourceDictionary> </Window.Resources> 但在“主窗口”上添加DataGrid后,显示字符串错误: <ResourceDictionary Source="GlassButton.

我的程序运行良好

  <Window.Resources>    

        <ResourceDictionary Source="GlassButton.xaml">
        </ResourceDictionary>
    </Window.Resources>    

但在“主窗口”上添加DataGrid后,显示字符串错误:

   <ResourceDictionary Source="GlassButton.xaml">

添加DataGrid后,Window.Resources的部分发生了更改,如下所示:

<Window.Resources>            
        <ResourceDictionary Source="GlassButton.xaml">
            <my:DepartmentDataSet x:Key="DepartmentDataSet" />
            <CollectionViewSource x:Key="DepViewSource" Source="{Binding Path=DEP, Source={StaticResource DepartmentDataSet}}" />
        </ResourceDictionary>

错误消息显示: “Property”System.Windows.ResourceDictionary.DeferrableContent“称为异常。”:行“10”的编号和行“29”中的位置。
致以最良好的问候

我找到了原因。我需要将代码放入“”中。有了这个添加的代码,程序运行得非常好

<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
             <ResourceDictionary Source="GlassButton.xaml"/>
    </ResourceDictionary.MergedDictionaries>
            <my:DepartmentDataSet x:Key="DepartmentDataSet" />
            <CollectionViewSource x:Key="DepViewSource" Source="{Binding Path=DEP, Source={StaticResource DepartmentDataSet}}" />
        </ResourceDictionary>