Please help. Is it possible to connect all the regions with PRISM? For example I have three regions and they have three Views. The first region has a menu with buttons. The second and third regions for example have RichTextBox. How can I send commands from the first region to the second and third region by pressing buttons? Thank you.
The prism library offers this feature out of the box and is well documented. All you need is the Event Aggregator and your own PubSubEvent published in one region and subscribed in the other.
Related
Does Prism have built-in support for having "groups" of views? If so, how is it done? What I'd like to do is have one regin, call it WizardRegion, where I can have different types of wizards load into that region. Let's assume I have two different wizards: signup and dowork. And each wizard has four pages or views. If I do the normal RegisterViewWithRegion() for each view then all eight views will be visible all the time. When I switch to the signup wizard I want the four views for signup to show. When I switch to the dowork wizard I want the four views for dowork to show.
Do I have to write my own view manager (or extensions) to do this work? Am I completely thinking about it incorrectly? Note that I do not want to have a SignupRegion and a DoWorkRegion.
Yes, you have to come up with some sort of view manager on your own. I believe there are some frameworks out there with this sort of functionality.
Using Prism alone you could use the event aggregator service to send messages to make views visible/collapsed.
If you are doing MVVM you could also bind the visibility of those views to a service/controller class where those properties are set.
You can also use a combination of the two.
Here is the overview of what I am trying to do. I have a region in the shell that is used for application modal dialogs. When a module wants to launch an application modal dialog it loads a custom Lightbox control into the region and fills it with the content I want to display (warning, wizards, etc). I have the region defined in the shell because I assume it needs to be there for the lightbox background to block out the whole window.
The immediate situation that comes to mind is what happens if two modules trying to use the region at the same time, is there any prismy way of preventing another module from accessing a region until after the current use of the region is finished?
If there are better ways to accomplish what I want I am open to suggestions.
You could use the RegionPopupBehavior from the Prism RI to display dialogs and have the dialog's content set as views into regions.
You can read more about that here: http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=65394.
I hope this helps.
Thanks,
Damian
I'm looking for a smooth method of managing toolbars (and menus) with mvvm in WPF.
Consider an UI with tabbed workspaces and heterogenous content (like Visual Studio). There the toolbars should be hidden or visible depending on the active tab. How would you design the view viewmodel for the toolbars?
I'd use a collection of toolbar-viewmodels and bind the ToolbarTray to it, but afaik that's not possible.
Any recommendations are apreciated.
Links to samples, best practice papers, etc. are welcome.
I had this same issue in one of my applications recently. I was using a Ribbon as my main toolbar, and based on what module was selected the buttons on the ribbon had to be hidden or shown. I came up with two different solutions... hopefully one will work for you.
The first solution would be to create a region in the shell of your application (it can be a Grid/Canvas/whatever) and dynamically load the desired toolbar into this region based on what tab the user clicks on. In other words, if you have 5 different tabs that require their own toolbar, create 5 UserControls that contain a toolbar and load the correct one into the region when the user clicks on the tab. Next you'll want to respond to the event of when the user clicks on a button on the toolbar. In my solution I used the Mediator approach to allow ViewModels to communicate with each other. It works, but I don't know that I would do it again that way... CAL is probably the better approach.
The other solution would be to create one toolbar with all of the required buttons and bind their visibility to the ViewModel. Based on the user's selection, set the visibility of the controls to whatever your requirements may be. Hopefully one of these solutions works for you.
by the way... what part of Germany are you from? I know a man with the last name of Stoll, so I wasn't sure if it was a common name or not...
I'm writing a prism application and would like to integrate Ribbon library in it. I want a Ribbon Window that would be used as a Shell with office-like tabs and tab groups. The modules should be loaded on demand depending on the tab selected by user. I don't want the tabs to be located in a region if this is avoidable. So I created a Ribbon window and some regions and get all kind of errors (cannot resolve dependency object, etc.). Is there somewhere a good example of such application or a tutorial? How to load the modules depending on the user's choice?
I started this thread but I didn't get an answer that could help me.
Thanks for any help and suggestions.
Have you implemented a RegionAdapter for the Ribbon? (I'm guessing you're trying to fill the Ribbon dynamically with a Region attached property)
See this link for details.
Make your shell a RibbonWindow and if you need commands over the whole application you can create applicationcommands.
Context:
I'm developing a WPF application which will contain a lot of different "screens". Each screen contains a which on its turn contains all the visual elements. Some elements trigger events (e.g., checkboxes), a screen has individual resources, etc.
The main application is "wrapper" around these screens: it contains a menubar, toolbar, statusbar and alike (in a DockPanel) and space to display one screen. Through the menubar, the user can choose which screen he wants to display.
Goal:
I want to dynamically load & display & (event)handle one screen in the space in the main application. I don't want to copy & paste all the "wrapper" stuff in all the different screens. And As I have many complex screens (around 300 - luckily auto-generated), I don't want to load all of them at the start of the application, but only upon request.
Question:
What do you recommend as the best way to realize this?
What kind of things should I use and investigate: Pages or windows or User Control for the screens? Does this affect the event handling?
Robbie, you can borrow the workspace concept from Josh Smith's WPF MVVM article. What you would do is have one hosting window (your wrapper) and load a workspace into this window. You can close the workspace and load a new one as needed, keeping only one open in your main window.
Link:
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
You can use a Frame to contain the variuos Pages.