This is my MainWindowViewModel.vb
Public Class MainWindowViewModel
Inherits ViewModelBase
Public Sub New()
End Sub
Private _test As String = "Success"
Public Property Test() As String
Get
Return _test
End Get
Set(ByVal value As String)
_test = value
RaisePropertyChanged()
End Set
End Property
End Class
This is my MainWindow.xaml
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Koala"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:MainWindowViewModel x:Key="MainWindowViewModelDataSource" d:IsDataSource="True"/>
</Window.Resources>
<Grid DataContext="{Binding Source={StaticResource MainWindowViewModelDataSource}}">
<TextBox HorizontalAlignment="Left" Height="23" Margin="156,103,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Text="{Binding Test}"/>
</Grid>
</Window>
And this is the error I get:
Error 1 The name "MainWindowViewModel" does not exist in the namespace "clr-namespace:Koala". \\psf\Dropbox\Programming\Windows\Koala\Koala\MainWindow.xaml 7 3 Koala
I can add a reference to the namespace Koala in the Window tag without problems. When I type <local:
, I get the option to use the MainWindowViewModel
tag. Whenever I add the x:Key
or not, from that moment the error occurs. (Re)building doesn't work, restarting VS2012 doesn't work. I searched dozens of similar problems but it I can't find a fix for mine.
I tried to add the reference through Blend and VS2012 but neither of them work. The odd thing is that I'm able to start the debug mode and see my form on the screen. Also, Success
appears in the TextBox
.