Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 在从app.xaml引用的资源字典中找不到app.xaml中的StaticResource_.net_Wpf_Staticresource - Fatal编程技术网

.net 在从app.xaml引用的资源字典中找不到app.xaml中的StaticResource

.net 在从app.xaml引用的资源字典中找不到app.xaml中的StaticResource,.net,wpf,staticresource,.net,Wpf,Staticresource,我遇到了这样一种情况:我试图解析资源字典中引用的数据模板中的可视组件,引用app.xaml标记的静态资源,请参见下面的示例 App.xaml <Application x:Class="App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx

我遇到了这样一种情况:我试图解析资源字典中引用的数据模板中的可视组件,引用
app.xaml
标记的静态资源,请参见下面的示例

App.xaml

<Application 
    x:Class="App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"      
    xmlns:composition="clr-namespace:Composition"
    ShutdownMode="OnMainWindowClose">
    <Application.Resources>
        <ResourceDictionary>
            <composition:ApplicationContainer x:Key="ApplicationContainer"/>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary
Source="pack://application:,,,/MyApp;component/Composition/DataTemplates.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:projectvm="clr-namespace:ViewModels.ProjectManagement"
                    xmlns:unity="clr-namespace:Extensions">
    <DataTemplate DataType="{x:Type projectvm:ProjectDocument}">
        <ContentControl>
            <!-- Custom Extension that resolves a component from
            the composition container -->
            <unity:Resolve Container="{StaticResource ApplicationContainer}"
  TargetType="{x:Type projectvm:ProjectDocument}" ContractName="ProjectDocument"/>
        </ContentControl>
    </DataTemplate>
</ResourceDictionary> 

错误就在上面。unity:Resolve行找不到
ApplicationContainer
静态资源。我不明白为什么。

这是一个运行时错误。我认为这可能与标记扩展上有一个staticresource有关,但idk没有这样做,在非依赖对象上使用动态资源时出错。您是否尝试将“ApplicationContainer”资源从App.xaml移动到DataTemplates.xaml(在ProjectDocument DataTemplate上方)中?您是否为此确定了解决方案或解决方法?刚刚碰到这个问题。可能会有帮助。