User avatar
aliagha.huseynli
Topic Author
Posts: 44
Joined: 29 Mar 2023, 10:17

Multiple ViewModel Connections in NoesisView

19 Feb 2024, 07:38

Hi Noesis Team members,

I have a ViewModel cs file with Monobehavior, INotifyPropertyChange.
It contains all data-binding properties.
Now I want to separate it into multiple view models that can operate concurrently.
However, I've encountered a limitation with
NoesisView.Content.DataContext = this;
which only permits a single view model connection.
How can I enable multiple view model connections simultaneously?

Thank you in advance for your assistance.
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Multiple ViewModel Connections in NoesisView

19 Feb 2024, 11:58

Hi, what do you mean by "multiple view models that can operate concurrently"?
A View can only be connected to a single view model at the same time, but inside the View you can point to different properties to access several sub-view models:
<Grid DataContext="{Binding ModelA}">...</Grid>
<Grid DataContext="{Binding ModelB}">...</Grid>
<Grid DataContext="{Binding ModelC}">...</Grid>
Is this what you are trying to do?
 
User avatar
aliagha.huseynli
Topic Author
Posts: 44
Joined: 29 Mar 2023, 10:17

Re: Multiple ViewModel Connections in NoesisView

20 Feb 2024, 07:32

Yes. Thanks. It works :)

Who is online

Users browsing this forum: Google [Bot] and 7 guests