c# - Working with local ViewModel in MVVM WPF application -


i having trouble accessing viewmodel when working view.

i have project named bankmanagerapplication. within have various files associated new wpf application. have created 3 seperate folders model, viewmodel , view.

at moment there usermodel class in model folder following fields;

namespace bankmanagerapplication.model {     public class usermodel     {         public string firstname { get; set; }         public string lastname { get; set; }         public double accountballance { get; set; }     } } 

a blank view in view folder grid inside;

<window x:class="bankmanagerapplication.view.mainwindowview"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindowview" height="300" width="300">     <grid>     </grid> </window> 

and blank viewmodel in viewmodel folder;

namespace bankmanagerapplication.viewmodel {     public class mainwindowviewmodel     {     } } 

when try reference viewmodel in xaml so;

<window x:class="bankmanagerapplication.view.mainwindowview"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindowview" height="300" width="300"         xmlns:viewmodel="clr-namespace:bankmanagerapplication.viewmodel">     <grid>         <viewmodel:mainwindowviewmodel></viewmodel:mainwindowviewmodel>     </grid> </window> 

i error

the name 'mainwindowviewmodel not exist in namespace "clr-namespace:bankmanagerapplication.viewmodel'

i have started learning wpf , error throwing me off before have begun

you cannot add grid control because not uielement. viewmodel datacontext of view:

<window x:class="bankmanagerapplication.view.mainwindowview"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     title="mainwindowview" height="300" width="300"     xmlns:viewmodel="clr-namespace:bankmanagerapplication.viewmodel">     <window.datacontext>        <viewmodel:mainwindowviewmodel></viewmodel:mainwindowviewmodel>     </window.datacontext>     <grid>      </grid> 


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -