[英]The name “ ” does not exist in the namespace WPF XAML file
我已經為此花了很長時間了。 在我的WPF項目中,我不斷收到錯誤消息,說“名稱....在名稱空間中不存在”。 這發生在XAML文件中,因此,我無法構建我的應用程序。
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
**xmlns:local="clr-namespace:MyProject.ViewModel"**
Height="576" Width="1024" Closed="Window_Closed">
然后在Window.Resources中創建我的資源:
<local:CurrentTimeViewModel x:Key="CurrentTimeViewModel"/>
這就是錯誤的出處。 我檢查了CurrentTimeViewModel文件,名稱空間正確,而且一切似乎正確。
CurrentViewModel:
public class CurrentTimeViewModel : INotifyPropertyChanged
我有什么想念的嗎?
更新:
我看到的唯一C#錯誤是“無法加載項目文件。根級別的數據無效第1行位置1
我會建議
在下面的行中更改本地資源的密鑰
<local:CurrentTimeViewModel x:Key="CurrentTimeViewModel"/>
至
<local:CurrentTimeViewModel x:Key="CurrentTimeViewModelChanged"/>
並嘗試。 與加載本地資源一樣,它可能會以某種方式影響。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.