0

我的程序运行良好。

  <Window.Resources>    

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

但在“MainWindow”上添加 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>

错误消息显示:“属性“System.Windows.ResourceDictionary.DeferrableContent”被称为异常。”:行数“10”和行数“29”。致以最诚挚的问候</p>

4

1 回答 1

0

我找到了原因。我需要将代码放入“< ResourceDictionary.Merged >”。有了这个添加的代码程序工作得很好!

<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>
于 2012-09-11T12:17:38.807 回答