I am an absolute newbie to the realm of WPF and MVVM. But the little I know has made me want to dig deeper. It sounds exciting!
I am working with the fluent ribbon control from http://fluent.codeplex.com/. Each Ribbon Tab has an associated View and a ViewModel. I do this change using the SelectedTabChanged event which gets fired on selecting a tab. The AddedItems collection of the SelectionChangedEventArgs has the name of the new tab so I can use that in code behind class to get it done.
I would like to know if this is possible without implement开发者_如何转开发ing any code behind. I tried to attach a dependency object so that the event can be attached as a command in the view model. But this failed at the last instance since it seems the Fluent Ribbon doesnt derive from the DepedencyObject.
Thanking in advance for your thoughts and views.
Are you adding tabs dynamically at runtime, or are you defining them in xaml?
If you are defining them in xaml, all you need to do is have a main viewmodel, for your main window, which holds the instances of the viewmodels for the different tabs. These should then be exposed as properties, to which you can then bind the datacontext of each tab.
If there is a 'Selected Item', 'Selected Tab' or some such property on the Ribbon, you can bind this to a 'CurrentTab' property in your main vm, if you need to know which tab is selected.
精彩评论