WPF: Passing an TabItem control to controller class?

You got it backward, at least to the MVVM approach. The controller (TurbineContoller) shouldn't reference the view (TabItem), the view should reference the controller. Create a collection of controllers and databind the collection to a tabcontrol.

The datacontext of each tab will be the controller which the tab will databind to.

I'm using WPF and the TabControl as my Menu. This generates a lot of code behind code because one file is controlling all the user actions. Then I was thinking that I could use a Controller class for every TabItem.

I used it and it works, but I don't like the outcome. I have to use the FindName() method on the TabItem that I pass to the Controller and it generates some ugly code that can be hard to debug (in my opinion at least). So is there any way to pass the TabItem so that I can find the Controls on the xaml page in my Controller?

For example I have TabItem1, TabItem2 and TabItem3. Each containing a page for the user to use. Then I want to pass TabItem1 to controller TabItem1Controller.

But then I have to use the FindName() method. Is my request possible?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions