在一個簡單的測試應用程序中獲得了用於數據綁定的智能感知,感謝我的previously raised question的答案,我現在試圖將我所學到的知識應用於實際應用程序中,正在努力。我又遇到了我不明白的問題。我的代碼片段低於 - 我不得不改變名稱,以保護可否信息:數據綁定智能感知不起作用 - 後續工作
名稱「MyViewModel」:
<Page x:Class="MyProject.Views.Pages.MyPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="450" xmlns:Converters="clr-namespace:MyProject.Converters" xmlns:ViewModels="clr-namespace:MyProject.ViewModels" Title="My View" SnapsToDevicePixels="True" KeepAlive="True" TextOptions.TextFormattingMode="Display"> <Page.Resources> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <Converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/> </Page.Resources> <StackPanel d:DataContext="{d:DesignInstance ViewModels:MyViewModel}"> <!-- ... --> </StackPanel> </Page>
我就行了
<StackPanel d:DataContext="{d:DesignInstance ViewModels:MyViewModel}">
收到錯誤消息不存在於名稱空間「clr-namespace:MyProject.ViewModels」中。
錯誤沒有意義MyViewModel
確實存在於MyProject.ViewModels
namspace中。 有什麼建議嗎?我試過了一個乾淨的重建。