TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Azarudeen Jamalmohamed
NA
21
8.9k
System.TypeInitializationException in Uwp using mvvm?
Nov 3 2016 7:29 AM
Viewmodel:
public class AddEngineerViewModel:BindableBase
{
IAddEngineerDataService _engineerDataService;
IDialogServices _dialog;
public AddEngineerViewModel(IAddEngineerDataService AddEngineerDataService,IDialogServices Dialog)
{
_engineerDataService = AddEngineerDataService;
_dialog = Dialog;
LoadCommand();
}
private AddEngineerModel _addEngineer;
public AddEngineerModel AddEngineer
{
get { return _addEngineer; }
set
{
_addEngineer = value;
RaisePropertyChanged("AddEngineer");
}
}
public ICommand AddEngineerCommand { get; set; }
public ICommand ViewEngineerCommand { get; set; }
private void LoadCommand()
{
AddEngineerCommand = new CustomCommand(Add, CanAdd);
ViewEngineerCommand = new CustomCommand(Views, CanView);
}
private void Views(object obj)
{
_dialog.ShowDialog();
}
private bool CanView(object obj)
{
return true;
}
private bool CanAdd(object obj)
{
return true;
}
private void Add(object obj)
{
_engineerDataService.Add_Engineer_Details(_addEngineer);
}
}
Locator:
public class ConstructionLocator
{
private static IDialogServices _dialog = new DialogServices();
private static IAddEngineerDataService _addEngineerDataServices = new AddEngineerDataServices(new AddEngineerData());
private static AddEngineerViewModel _addEngineerViewModel = new AddEngineerViewModel(_addEngineerDataServices, _dialog);
private static ViewEmployeeViewModel _viewEmployeeViewModel = new ViewEmployeeViewModel(_addEngineerDataServices, _dialog);
public static AddEngineerViewModel AddEngineerViewModel
{
get { return _addEngineerViewModel; }
}
public static ViewEmployeeViewModel ViewEmployeeViewModel
{
get { return _viewEmployeeViewModel; }
}
}
When navigate to view on button click it shows Type initializer threw exception in locator file of addengineerviewmodel static property. Above are my locator and viewmodel. what would be the problem?
Reply
Answers (
0
)
How to add two textbox value using MVVM in Uwp?
Binding Two Controls in xamarin forms