2017-04-15 43 views
0

在原型項目中編輯ControlTemplate後,我決定將自定義ControlTemplate移到我的主項目中。這並沒有開箱的預期時,Visual Studio通知我下面的錯誤:SystemColor缺失InactiveSelectionHighlightTextBrushKey

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

有沒有在XAML源沒有亮點和警告,所以並不清楚發生了什麼事。去的「InactiveSelectionHighlightBrushKey」的定義,我沒有看到SystemColors成員列表中的條目:

enter image description here

我發現在我的工程樣機的對象瀏覽器的成員。 SystemColors類在我的主項目中如何不完整?

+1

您定位的是哪個框架版本?對MSDN的支持是在4.5中添加的:https://msdn.microsoft.com/library/system.windows.systemcolors.inactiveselectionhighlightbrushkey(v=vs.110).aspx –

+0

@FlatEric .NET Framework 4.5.2 – oddRaven

回答

0

基於this comment我開始尋找框架版本的差異。

由於某些原因,即使項目是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