I am writing a WPF application in C# according to the MVVM model. I have a MainWindow which consists of several views: MenuView, ContentView1, ContentView2, . . . and so on.
The MenuView, ContentView1, ContentView2 . . ., are all cousins (not bothers) in the XAML tree.
The MenuView consists of few buttons. Each button has a unique ID. The Content Views (all of them) should receive the menu ID of a selected (clicked) button. i.e. when a button in the MenuView is clicked I want to pass its ID to ContentsViews1, ContentsViews2 and so on.
I am not sure what is the best way to pass data between the views.
I thought to attach an event handler to all menu buttons which reside in the MenuView. The handler is implemented in MainWindow class (which is the root view). This handler will raise a RoutedEvent (with tunnel option) to all children views.
Is there a better way to do it? Is it the best way considering performance issue?