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
Anja Simonsen
NA
41
15.5k
Wpf Mvvm Multiple (2) views and the same instance of a viewmodel
Apr 21 2021 6:54 PM
My solution is created in projects:
AnsiBug.MainWindow = the UI
In the above there is an App.xaml
Dal.Account.DalCategory
Model.Account.CategoryModel
ViewModel.Account.CategoryViewModel
In the next project (which is usercontrols) I have 2 usercontrols/views
Views.Account.AccountObsoleteView.xaml
Views.Account.AccountObsoleteViewCategoryNew.xaml
Now I want to make one single instance of the CategoryModel in the 2 usercontrols.
I have read I should write following in the app.xaml
<local:MainWindow x:Key=
"ViewModel.Account.CategoryViewModel"
/>
An in the two usercontrols.
DataContext=
"{StaticResource ViewModel.Account.CategoryViewModel}"
There is no error before running the code, but when running it fails in the first usercontrol Views.Account.AccountObsoleteView.xaml
The InnerException sais Ressourcen ViewModel.Account.CategoryViewModel was not found.
So it can't find the CategoryViewModel from the ViewModel project.
Can you see why (and telling me the error I make)?
And if you are asking why - is because, that I want to get data from usercontrol 2 to 1
Best regards
Simsen :-)
Reply
Answers (
0
)
file .txt in python
Passing database data to _loginPartial.cshtml