I have a WPF application using PRISM. The application is divided into two sections. The left pane is a menu pane and the right pane is a details pane. I have a toolbar also in the container pane which is a user control.
Now, I want that when I click the toolbar option I should be able to replace the right pane (details pane) with new user control/window. How can I do that? Currently, I have the following code in the toolbar edit button click which opens a new window I do not want a new window I want to replace the right pane window (details) window.
private void EditButtonClick(object sender, RoutedEventArgs e)
{
Window userEditWindow = new Window
{
Title = "User Edit",
Content = new UserEdit(),
Width = 600,
Height = 600
};
userEditWindow.Show();
}
Here is what the user interface looks like:
_______________________________________________________________________
PRISM shell container begins
________________________________________________________________________
| User control containing toolbar (edit, new, update, delete)
menu user control |____________________________________________________
|details pane user control
|
|
__________________________________________________________________ |_______________________________________________________________
PRISM shell container ends
_________________________________________________________________________
Above you can see the layout of my app! As you can see everything is inside the PRISM shell container. I am handling the events from user control toolbar in the code behind for the usercontrol toolbar as shown above. All I want is to replace the details pane when the toolbar is clicked. But I have no idea how to do that?
EventAggregator
) to broadcast a ChangeContentView message, and have my ViewModel subscribe to receive that kind of message and change the item displayed in the Content pane. If you're interested, I even have a helper wrapper written for PRISM'sEventAggregator
that simplifies how it's used for broadcasting and subscribing messages on my blog – RachelContentControl
, you can setContentControl.Content
to whatever UserControl you are trying to display instead. I have an example in another answer here of this style of navigation if you want. Also don't be afraid of PRISM'sEventAggregator
. It's not actually that complex, especially with that helper wrapper, and it makes your life much easier if you're working with the MVVM pattern :) – Rachel