I am trying to use my viewmodel as my window’s datacontext but am getting the error:
ViewModel is not supported in a Windows Presentation Foundation (WPF) project.
Clearly, I am not understanding something about the syntax and databinding my window to my view model, but I am not sure what it is that I don’t know.
Any advice on what I should be reading?
<Window x:Class="SunnyBeam.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SunnyBeam" Height="488.358" Width="1014.552">
<Window.DataContext>
<ViewModel/>
</Window.DataContext>
<Grid>
</Grid>
</Window>
Usually I set DataContext through codebehind like that:
In place of MyViewModel may be anything you want to bind to.