SystemColor 缺少 InactiveSelectionHighlightTextBrushKey

SystemColor is missing InactiveSelectionHighlightTextBrushKey

在原型项目中编辑了一个 ControlTemplate 之后,我决定将自定义的 ControlTemplate 移动到我的主项目中。这并没有像预期的那样开箱即用,Visual Studio 通知我以下错误:

Error Cannot find the static member 'InactiveSelectionHighlightBrushKey' on the type 'SystemColors'.

xaml源码中没有高亮和警告,所以不清楚哪里出了问题。转到'InactiveSelectionHighlightBrushKey'的定义,我没有看到SystemColors成员列表中的条目:

我确实在我的原型项目的对象浏览器中找到了该成员。为什么我的主项目中的 SystemColors class 不完整?

基于我开始寻找框架版本的差异

出于某种原因,即使项目的 TargetFramework 在属性中设置为“.NET Framework 4.5.2”,PresentationFramework.dll 和 WindowsBase.dll 的引用路径仍指向 / v4.0 路径。在属性中将目标从 4.0 更改为 4.5.2 没有任何效果。我不得不手动删除和添加引用。

.csproj 上的 git diff 显示以下更改:

-    <Reference Include="PresentationFramework">
-      <HintPath>..\..\..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\PresentationFramework.dll</HintPath>
-    </Reference>
+    <Reference Include="PresentationFramework" />

WindowsBase.dll 相同。 The explicit definition of HintPath probably caused the DLL references not to change from path version.