You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a TabControl which has an ItemsSource filled in. A new tab is created based on web socket messages received. The ItemsSource is an ObservableCollection to a Model that holds the data from the socket message. I want to keep the UI separate from the business logic. Thus, we want a view model for each view.
Argument
The argument of using View Injection vs View Discovery (using RequestNavigate vs regionManager.RegisterViewWithRegion) makes us think that if I have to run code to RequestNavigate in my model that would mean the business logic is making a UI decision. Thus we would like View Discovery. The assumption is a view model would be created for the view. Yet we want to know the instance of the object that is linked to this tab inside of the newly created view model.
We tried
The TabControl we are setting the HeaderTemplate and ContentTemplate. If in the Xaml I put in the view in the templates, example ( ) they bind to the instance of each record in the ItemsSource. The INavigationAware interface isn't used.
We also tried putting a ContentControl setting the region manager and region name. If we did navigate when adding the record to the TabControl's ItemsSource's collection, the RequestNavigate ran before the UI was loaded. NOTE: We saw RegionContext but didn't know how to get it to the view model.
Question
Let me know if you need more detail. I could setup a new GitHub repo with a sample app to try to give more context.
Will view discovery work for what we are trying to do? Can we have a view model for each view and still have it link around the model that is bound to the tab control.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Current problem
We have a TabControl which has an ItemsSource filled in. A new tab is created based on web socket messages received. The ItemsSource is an ObservableCollection to a Model that holds the data from the socket message. I want to keep the UI separate from the business logic. Thus, we want a view model for each view.Argument
The argument of using View Injection vs View Discovery (using RequestNavigate vs regionManager.RegisterViewWithRegion) makes us think that if I have to run code to RequestNavigate in my model that would mean the business logic is making a UI decision. Thus we would like View Discovery. The assumption is a view model would be created for the view. Yet we want to know the instance of the object that is linked to this tab inside of the newly created view model.We tried
The TabControl we are setting the HeaderTemplate and ContentTemplate. If in the Xaml I put in the view in the templates, example ( ) they bind to the instance of each record in the ItemsSource. The INavigationAware interface isn't used.We also tried putting a ContentControl setting the region manager and region name. If we did navigate when adding the record to the TabControl's ItemsSource's collection, the RequestNavigate ran before the UI was loaded. NOTE: We saw RegionContext but didn't know how to get it to the view model.
Question
Let me know if you need more detail. I could setup a new GitHub repo with a sample app to try to give more context. Will view discovery work for what we are trying to do? Can we have a view model for each view and still have it link around the model that is bound to the tab control.Beta Was this translation helpful? Give feedback.
All reactions