Silverlight Page Navigation with usercontrol and MVVM Light - silverlight

I'm developing a silerlight application and have settled on the MVVM Light framework. One of the things I'm trying to do is create a "LoginStatus" control that can be used on multiple locations because we have different layouts that the pages are grouped into.
My challenge is how to redirect the page from a user control. When the users "logout" I want to redirect them to a different page not just a different View. Anybody have any thoughts or some examples that might do something like this.
Most of the examples I have seen out there just change the status on the current view.
dbl

If you really want to navigate to a new page - i.e. leaving the silverlight application - you can use the Navigate method of the System.Windows.Browser.HtmlWindow class (documentation).
System.Windows.Browser.HtmlPage.Window.Navigate(
new Uri("http://silverlight.net")
);
Otherwise, if you do not want to leave the silverlight application you simply navigate to a default view that informs the user that he is not logged in.
Edit:
For implementing a navigation service in Silverlight see for example this post or this post.

Related

Best practice to handle extjs refresh page

I wrote an ExtJS application like this:
the sub menu is dynamic added by clicking the button on the left.
The question is :
as the sub panel is created dynamically, so if I refresh the whole page, the panel will go away.
What I expected is it could still display the same content before refresh pages.
So, my question is how to handle this in ExtJS?
Do I need to record the current panel information into Ext.App?
ExtJS is a framework to build Web Applications that run inside the browser.
With Web Applications, just like normal applications, you don't close the program and start it anew (like a browser refresh does) just because someone wants to switch to a different toolbar or look at different data. You work with multiple panels, switch between them, and/or open windows.
You could for instance generate multiple panels inside a container with card layout, and bring to front the panel that you want to show right now.
If you have a license that allows you to use Sencha Architect, there is a nice "navigation" sample available in Architect from where you can start and look at how it's done.

Silverlight custom navigation window

I am developing a Silverlight MVVM app. I have a window with a frame. I have 3 pages, the first for data input, the second for editing the data, and the third for the user to review data and commit changes.
I added 2 buttons, "previous" and "forward", so that the user can navigate.
The "previous"button is going to use the NavigationService.GoBack() method, but I cant figure out how the "next" button is going to know what the next page is.
Don't use a navigation application. You'd be much better off with a MVVM framework like Caliburn.Micro and use a shell view to display the content instead of a frame.

Embedding of Webbrowser in WPF Form with Address bar + Buttons

I wouldlike to embed a webbrowser in a WPF application. The browser should look like a normal browser, with address bar, back and forward button and status bar. Is there a way how that could easily written in XAML, with a direct databinding of the address to a textbox, with a direct routing of events from the buttons to the webbrowser object, and the enabling back?
Why not?
Here and here are uploaded some screenshots from our application which has WebModule inside and is able to work like browser.
In our implementation we used Windows Forms WebBrowser control as browser engine and MVVM as communication pattern. Model has navigation commands (forward, back, ...) that raise proper events. View is handling this events and delegate requested actions to inner WebBrowser component. Additionally view is handling WebBrowser's events (NewWindow, DocumentCompleted, Navigating, Navigated) and setting up model's state.
Model and view together contain about 500 lines of code (I don't think it's very much, do you?).
Of course, I should mention, that due to using IE engine this browser could have some problems on complicated web-sites.
P.S. We didn't use System.Windows.Controls.WebBrowser because it does not provide access to NewWindow event.
P.P.S. I've posted this answer from browser in our WPF application. Good luck!

What is the difference between "User Control" and "Page" in Silverlight?

I am really new to Silverlight. I am working through some of the sample codes I found online.
I notices sometimes a new "Page" is added, and sometimes a new "User Control" is added.What are the differences between those 2?
Btw, when I tried specifying the URL for a hyperlink as "www.apple.com", there is an error saying "www.apple.com" can not be found. Are there anyway of specifying an URL for a website for a HyperlinkButton?
Thanks :)
In SL3 and up; a Page correlates to the Navigation framework whereas a UserControl is a control providing a defined set of functionality using multiple controls which can then be used within a Page.
User Control:
When you build your project , any user control that you created will appear in the toolbox also. You can drag and drop it like any other control (like a button or a grid).User controls are used for enhanced flexibility. You can customize your controls, set as many properties you want , and it really simplifies things without going for creating custom controls.
Page:
However, when you come to a Page, you can use it mostly for Navigation . It can contain other controls , but it is mainly intended for Navigation within Frames.

How to handle Refresh and Reset in WPF application in MVP application

I am developing an windows UI application in WPF with MVP architecture with C#.
The application will interact to sqlserver and displays the data to the user.
I have 2 buttons REFRESH and RESET. which refreshes the page and resets the page to the home page respectively.
As I searched in few forums,navigationservice is recommeneded,but I couldnt see navigationservice.refresh() command
Refresh should refresh the page (current page) and the reset should reset to the homepage as per my appication.
Please help me in doing this.
Thanks
Ramm
You need to create custom commands for each of your buttons. The RefreshCommand can reload the data bound to your view, and you can use the ResetCommand to call the NavigationService to navigate to your home page.

Resources