I have a simple Silverlight application that consists of four pages (XAMLs).
Navigation is done by calling:
//from XamlPageA
this.Content = new XamlPageB();
Is this the right way. I need to have the entries in Browser history so that users can go page to the previous page(s). How can I do it.
You are bypassing the navigation system completely by setting content manually. You would have to implement updating the browser history yourself if you do it that way (certainly possible, but quite tedious).
A simpler approach is to generate a "Silverlight Business Application" project and see how the page navigation is simply handled with hyperlink buttons. All the browser history plumbing is done for you as is the mapping from URL to views.
e.g. A button with NavigateUri="/Home" will cause a view named Home.xaml to load into the navigation:Frame of the MainPage window.
if you look into the navigation:Frame element of MainPage.xaml, you will see a number of UriMapping entries like this:
<uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>
<uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>
They provide the pattern matching to convert from URLs to views.
Hope this helps your project.
Related
So i have a splash screen and a LoginScreen, after the user logs in, then he's presented with a MasterDetailPage, and there's a option to logout, what i want to achieve is to clear the masterdetail navigation and go to the login page using Prism.Forms
But when i do "NavigationPage/LoginPage", it still has the MasterDetailPage Navigation active, is there a way to disable this behavior using Prism
MasteDetailNavigation]3]3
Any help would be helpfull
As I can see from your question you want to reset navigation stack and master-detail page and navigate to "clear" page for your login page. If you want to achieve that, you don't want to use NavigationPage/LoginPage you will need to use Absolute navigation, because using Absolute navigation in Prism you will be able to reset the entire navigation stack and it is equivalent to:
Application.Current.MainPage = new SomePage()
You can find more about it here.
But basically what you need to do is to use Prism Absolute navigation like this:
//absolute short-syntax
_navigationService.NavigateAsync("/YourPage"); //notice the prefix /
//absolute URI-syntax
_navigationService.NavigateAsync(new Uri("http://www.brianlagunas.com/YourPage", UriKind.Absolute));
Code example is from Prism Library docs site
Also I recommend you to take a look at my blog post How to make Master-Detail Page Navigation menu in Xamarin.Forms with Prism
Wishing you lots of luck with coding!
I am using the latest version of Prism.MVVM in Xamarin.Forms. In this, if I try to navigate to second page from the first page, the first page is initialized once again. i.e., the constructor of the first page is called once again.
For example, I am having Page1.xaml and Page2.xaml pages with their respective view models(those will be created and registered automatically while creating in prism).
I navigating to Page2 from Page1 like below,
NavigationAsync("Navigation/Page1/Page2")
While navigating, Page1.xaml's constructor is called so that the page is created newly which lead I could not able to maintain the Page1.xaml instance. Also, please note that Page1.xaml is a Master-Details page.
Is this a behavior in Prism? If so how can I overcome this?
Thanks in advance.
Navigating away from a XAML page destroys it in UWP. You can preserve a page’s state data (and avoid re-construction) by adding a single line in a XAML page’s tag:
NavigationCacheMode="Required"
Does it work the same in Xamarin?
I've been looking for hours on how to hide two buttons within the site actions menu (New Page & Manage Site Content and Structure).
Heres my specific case... I have a List which when a user is viewing, I want to be able to remove certain buttons. Also dependant if the user is an administrator, these buttons should show or not... Currently I have been able to remove these two buttons utilizing HideCustomActions (code below). The issue with hide custom actions is that there are no attributes to specify a list or content type for this to function off. Also there is no attribute like in CustomActions that will show the buttons to administrators only (Sample code of what I want to do in CustomActions below).
HideCustomActions code:
<HideCustomAction
Id="HideCreatePublishingPage"
GroupId="SiteActions"
HideActionId="PublishingSiteActionsMenuCustomizer"
Location="Microsoft.SharePoint.StandardMenu">
</HideCustomAction>
CustomActions code:
<CustomAction
Id="HideNewPage"
GroupId="SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
RegistrationType="List"
RegistrationId="10037"
RequireSiteAdministrator="TRUE">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="WHAT GOES HERE?" /> <!-- PublishingSiteActionsMenuCustomizer should go here but i dont have the id -->
</CommandUIDefinitions>
</CommandUIExtension>
</CustomAction>
If theres any details missing or if I am not explaining myself properly please let me know and I will update!
As far as I understood you, you want to hide an action in the Site Actions menu just when you are in some special list / page.
This doesn't work out of the box. The HideCustomAction element simply doesn't offer to "hide only when user is on page XYZ". Either it hides the action or it doesn't - that goes for all users everywhere. Especially when you're talking about the site actions menu which is (as the name implies) site wide.
Your only choice to do what you want, to hide the menu items only for certain users as well as only hide them on certain pages is to use JavaScript (or server side code). With the JavaScript you have to search for the menu items and hide them if your logic applies.
I have created a web page that I use as a small dashboard to hold issue or no issue. It works great. The page uses an .aspx and .aspx.cs. I would like to be able to reuse the information on this page on other pages. My site already uses master pages and I have not been able to find an easy way to include this information.
How can I use an include from a page that has coding in the code behind easily?
Typically you use Web User Controls for this.
Web User Controls allow you to package up other controls into one that you can drop onto multiple pages. They are great for common UI items such as address entries, dashboards, etc. Basically anything that needs to be the same across multiple pages.
At the risk of seeming very obvious - do you mean usercontrols. These will allow you to reuse chunks of functionality across your site.
I guess this question falls into two categories: User Controls, and Code Reuse. Not sure which one you are after.
User Controls
If you are talking about the controls on your page you will want to create a common user control.
Code Reuse
You need to create a common class (whether it is static or not depends on how you intend to use it) and define functions within that class.
For instance, lets say you have a page that you want to print "Hello World!" on any aspx/.cs page.
You could do this
public static class MyClass
{
public string PrintHelloWorld()
{
return "Hello World!";
}
}
Then you call it from any of your pages like so:
MyClass.PrintHelloWorld();
Right click on the project > Add New Item...
Select User Control (.ascx)
Put your markup & code behind there.
Then you add that control in any other page (includding other controls [although I wouldn't recommend that])
It sounds like you may want to create an ascx User Control.
http://msdn.microsoft.com/en-us/library/ie/2x6sx01c.aspx
I am writing a website with Visual Studio 2008, C# 3.5 and ASP.NET MVC 2. I put the navigation bar in the masterpage.But there is problem that I will not know which button is needed to be highlight(current page) in the navigation bar.
I want get the current page that need to be highlight by masterpage self (not through the content page).And I don't think it is a good way to get the current page by url string.Because I have no idea about the final url is.
So how can I do this?
I guess you could set a ViewData["currentPage"] value in the Action methods, this would allow you to process that ViewData in the Masterpage. That is, however, off the top of my head and I'm sure there's a more elegant way to do this.
When you click the link in the navigation bar (in the master page) that should be triggering a controller action that will decide which view content page will be shown. In that action method you can (as Lazarus suggests) add some data identifying the current page to ViewData that will be picked up by the master page to modify the navigation bar.