I have created a custom Menu User control in WPF Browser application. How can I achieve Navigation from one page to other page using this Custom Menu User control from Main page. The pages would be displayed in other Frame control of the Main page.
There are different options to achieve this. Can you provide more details on how you're loading your UI? (i.e. Prism regions/modules, Data Templates, etc.)
My general suggestion would be one of two options:
Use a mediator pattern to have the menu control notify the frame control. MVVM Light has an easy to use Messenger implementation, which is a great toolkit to explore, in my opinion.
Have both controls contained in one "parent" control (or view model if you're using MVVM) which can then communicate to the frame control since it contains both menu and frame controls.
HTH,
Ben
Related
I'm developing WPF application using PRISM. I have two regions :
Ribbon region (which has got buttons to launch views from different modules)
View Region (in which views from different modules will be loaded but one view at a time)
I have separate module assemblies for Ribbon and views (i.e. CustomerModule, OrderModule, etc.). My ribbon has got buttons which should load view from modules i.e. pressing "Customer" button should load the specific view from "CustomerModule", pressing "OrderModule" should load the specific view from "OrderModule", etc.
How should I implement the command for my ribbon buttons to launch the view from different module assemblies? I'm not sure on how I can access the view module information into my ribbon module?
You can just call the RequestNavigate method of the ViewRegion from each button's command method as corresponds:
void OnCustomerButtonClicked()
{
this.regionManager.Regions["ViewRegion"].RequestNavigate(new Uri("CustomerView", UriKind.Relative));
}
You should then define every navigation request on each button's command method to properly navigate to the selected View.
You may find more information regarding Navigation on the following Prism Guide chapter:
View-Based Navigation
I hope this helps.
Have begun a WPF app following mvvm pattern and have hit an issue. I have a Customers page which has a number of searches and returns a list of customers. When I double click a record I want to be able to navigate to the Customer view so user can view/edit details.
Is this possible without using MVVMLight or WAF or PRISM(as I have struggled for a bit getting head into PRISM fully!!!) without forcing my view model to have knowledge of my application?
Thanks
Some people use Dependency Injection to connect VMs with Views in a decoupled way. Take a look at Unity
I would use a seperate / underlaying shell view & viewmodel with just the structure of your ui layout (some grids for positioning navigation, menu, search or content areas)
Then position your application views / controls the shell view. (maybe with some Visibility Bindings)
The main purpose of the shell viewmodel is to coordinate the flow of your ui. For example what control should hide or show based on some events of its child controls.
You could use an eventhandler in your search, wich is registered in the shell viewmodel, to show / hide your different content views.
Another approach could be a ContentPresenter.
I have a Silverlight application and I am trying to make each step of a wizard in XAML files, instead of hard-coded C#.
The problem is that I don't understand how I am going to switch between them after click on next button of each screen.
What is the best way to do this? I saw some tutorials on the internet about XAML dynamically loaded but none of them seem to work with me :/
Use a ChildWindow as your parent window. Then create multiple UserControls which will be framed in the content of the parent window. In the code-behind of the parent window, load the user controls into a list and set the visibility to 'Collapsed' for all of them but the first. When the user presses the Next/Prev buttons, pull the appropriate UserControl from the list (keep track of the current index) and make it 'Visible' while making the current control 'Collapsed'.
All of your navigation code will be in the parent window, but the parent window won't be concerned about the content of the wizard steps itself.
Each UserControl can be coded in XAML as a separate control so you still maintain a separation of the control from your wizards navigation logic.
You can then create a class type that will hold all of the options for the various wizard controls. Pass a reference to an object instance to each of the controls for them to update. When you get to the end of the wizard, your option object should maintain the state of all the wizard steps and the parent window can return that to the application.
I would suggest looking into the Silverlight Navigation Framework. It allows you to use "urls" to navigate between "pages" (which are your XAML user controls). It also also users to use the back and forth buttons in the browser, which may or may not be something you want to allow.
There is a VS 2010 template when you choose New Project, Silverlight, "Silverlight Navigation Application" that will help get you started.
Is this possible?
I used a Frame control and:
show(ex:showwindow.xaml)
But I get this error:
root element is not valid for navigation
sure you can navigate (show) a window by using:
YourFrame.Navigate(YourWindow);
However I don't like much this multi-window approach, better create some user controls for segmenting your application.
It is more common to use the Page class with the Frame control. Windows, in WPF are the top level items, with their own titlebar, chrome etc. Also, the Page can tap into the NavigationService provide by the framework.
more info about Navigation from Microsoft
I have a datagrid in my Silverlight-3 application.
When I select a row in the datagrid, I need to able to go to a new page which contains a dataform having a detailed view of that particular row.
I dont want to use "RowDetailsTemplate" property in datagrid.
I want to navigate to a new page which contains my dataform.
How can I achieve that?
There are MANY ways to achieve what you want to do.
If you are looking for a deep-linking approach, you can look into the Silverlight Navigation Framework which is shipped with Silverlight 3.
You might also look into using a ChildWindow as a modal dialog to display the page.
For displaying the data item, you might consider using the DataForm control.