Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.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
C# 运行时未找到资源密钥?_C#_Wpf_Xaml_Resources - Fatal编程技术网

C# 运行时未找到资源密钥?

C# 运行时未找到资源密钥?,c#,wpf,xaml,resources,C#,Wpf,Xaml,Resources,我的一个WPF应用程序有一个相当奇怪的问题: 我声明了一个ControlTemplate作为静态资源,我可以在Visual Studio Designer中使用它-但是在运行时,找不到该资源 我的WPF代码(简称): 编辑№2:当使用IntelliSense观察this.Resources的值时,我得到以下异常: XAML-Knotenstream: StartObject fehlt vor StartMember "System.Windows.Controls.ContentControl

我的一个WPF应用程序有一个相当奇怪的问题:

我声明了一个
ControlTemplate
作为静态资源,我可以在Visual Studio Designer中使用它-但是在运行时,找不到该资源

我的WPF代码(简称):

编辑№2:当使用IntelliSense观察
this.Resources的值时,我得到以下异常:

XAML-Knotenstream: StartObject fehlt vor StartMember
"System.Windows.Controls.ContentControl.Content".
也就是说

XAML node stream: StartObject is missing before StartMember
"System.Windows.Controls.ContentControl.Content".

我自己通过使用UserControl而不是模板控件解决了这个问题。

我遇到了一个KeyNotFoundException,在generic.xaml中定义了一个控件模板

引发异常:PresentationFramework.dll中的“System.Collections.Generic.KeyNotFoundException” 引发异常:System.Xaml.dll中的“System.Xaml.XamlObjectWriterException” 引发异常:PresentationFramework.dll中的“System.Windows.Markup.XamlParseException”


从TemplateBinding切换到Binding RelativeSource={RelativeSource TemplatedParent}解决了这个问题。

如果从
ControlTemplate
中删除
x:Name=“tmplt”
会发生什么?@SzabolcsDézsi:异常保持不变:/我刚刚用(xaml)运行了一个测试[您提供了减号部分,它工作正常。我怀疑您收到的错误来自代码的其他部分。请重新阅读异常或复制并粘贴到此处full@Xiaoy312:我会将我的异常结果添加到我的问题中,但我想说的是,您提供的链接无效
XAML node stream: StartObject is missing before StartMember
"System.Windows.Controls.ContentControl.Content".