Breadcrumb not displaying correctly when i land to same page through two different pages - breadcrumbs

I have two ways of getting to PageX.
Home-->PageA -->PageB -->PageX--->PageY
(One is gong to Home page and then to PageA then PageB and then to PageX)
Home-->PageX-->PageY
(Second way is directly clicking on PageX from Home)
This is my MVC.siteMap
<mvcSiteMapNode title="Page A" controller="PageAController" action="PageA" >
<mvcSiteMapNode title="PageB" controller="PageBController" action="PageB">
<mvcSiteMapNode title="" controller="PageXController" action="PageX">
<mvcSiteMapNode title="" controller="PageYController" action="PageY" />
</mvcSiteMapNode>
</mvcSiteMapNode>
</mvcSiteMapNode>
<mvcSiteMapNode title="" controller="PageXController" action="PageX">
<mvcSiteMapNode title="" controller="PageYController" action="PageY" />
</mvcSiteMapNode>
Now issue i am facing is when i go to PageX from Home directly. I expect breadcrumb to display 'Home/PageX' but instead i am getting 'Home / PageA / PageB / PageX'.
Where i expect 'Home/PageX/PageY' also i am getting 'Home / PageA / PageB / PageX / PageY'.
Any suggestions/help in this regard is highly appreciated.Thanks in advance.

Related

How to destroy the tab pages when navigating to the login page on logout in Xamarin Forms Shell?

In Xamarin Forms Shell, the content of AppShell.xaml is:
<Shell ...>
<ShellContent Route="login" ContentTemplate="{DataTemplate local:LoginPage}" />
<TabBar Route="home">
<ShellContent Route="Tab1" ContentTemplate="{DataTemplate home:Tab1Page}" Title="tab1" />
<ShellContent Route="Tab2" ContentTemplate="{DataTemplate home:Tab2Page}" Title="Tab2" />
</TabBar>
</Shell>
The login page is displayed first.
After user1 logs in, the tabs are displayed with user1 content. The login page is not destroyed (why?).
After logout the login page is displayed again. The page is not recreated as it was not destroyed at first. Also the tabs are not destroyed (why?).
Then user2 logs in: the tabs are displayed again, but not recreated. They still display user1's content.
After login i'm using this code to force remove the login page from the navigation stack:
foreach (var page in Shell.Current.Navigation.NavigationStack.Reverse().Where(p => p != null))
Shell.Current.Navigation.RemovePage(page);
await Shell.Current.GoToAsync($"//home/Tab1");
I'm using Shell.Current.GoToAsync("//login"); after logout.
It seems the issue is caused by the static declaration in AppShell.xaml which caches all the created pages.
What's the correct way to implement that common scenario ? (i'm not using any flyout)
For this,I think you can refer to article Creating a login flow with Xamarin Forms Shell.
The Shell is structured as follows:
<Shell>
<!-- Loading/Start Page -->
<ShellItem Route="loading">
<ShellContent ContentTemplate="{DataTemplate local:LoadingPage}" />
</ShellItem>
<!-- Login and Registration Page -->
<ShellContent Route="login"
ContentTemplate="{DataTemplate local:LoginPage}">
</ShellContent>
<!-- Main Page -->
<FlyoutItem Route="main"
FlyoutDisplayOptions="AsMultipleItems" IsTabStop="False">
<ShellContent Route="home"
IsTabStop="False"
ContentTemplate="{DataTemplate local:MainPage}"
Title="Home" />
</FlyoutItem>
<MenuItem Text="Logout"
Command="{Binding ExecuteLogout}" />
</Shell>
For the login page, we would set it like this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
...
Shell.PresentationMode="ModalAnimated"
...>
...
</ContentPage>
And whenever you navigate modally, it is always a good idea to override the back button navigation in the code behind of the target page as follows:
protected override bool OnBackButtonPressed()
{
return true;
}
And there is a sample included in above article, you can check it here.

Why Prism's Master Detail Page structure is different from Xamarin.Forms?

I developed one app about months ago with Prism. It's great tool that make perfect structure for my app.
However, today I tried to pick up that app and fix some things that pending for a long time. I used Master Detail page in my app, and today I suddenly found that actually the structure for how I developed this Master Detail page using Prism is kind of out of my knowledge.
So, here it is.
Basically my MasterDetailPage is like this:
<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"
mc:Ignorable="d"
x:Class="JapaneseLearnPrism.Views.MenuPage">
<MasterDetailPage.Master>
<NavigationPage Title="Menu" Icon="ic_hamburger.png">
<x:Arguments>
<ContentPage Title="{Binding Title}">
<ListView ItemsSource="{Binding MenuItems}"
SelectedItem="{Binding SelectedMenuItem, Mode=TwoWay}"
SeparatorColor="LightGray"
RowHeight="60"
SeparatorVisibility="Default"
BackgroundColor="#e8e8e8">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout VerticalOptions="FillAndExpand"
Orientation="Horizontal"
Padding="20,10,0,10"
Spacing="20">
<Label Text="{Binding PageIconText}" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="Medium" VerticalOptions="Center" />
<Label Text="{Binding Title}" FontSize="Medium" VerticalOptions="Center" TextColor="Black" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Behaviors>
<b:EventToCommandBehavior EventName="ItemTapped" Command="{Binding NavigateCommand}" />
</ListView.Behaviors>
</ListView>
</ContentPage>
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Master>
</MasterDetailPage>
And the navigation path is this in App.xaml.cs file.
await NavigationService.NavigateAsync(nameof(MenuPage) + "/" + nameof(NavigationPage) + "/" + nameof(Views.MainPage));
But if I look at lots of the Xamarin.Forms samples, the MasterDetailPage is actually different.
They are going to do like below:
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MasterDetailPageNavigation;assembly=MasterDetailPageNavigation"
x:Class="MasterDetailPageNavigation.MainPage">
<MasterDetailPage.Master>
<local:MasterPage x:Name="masterPage" />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<x:Arguments>
<local:ContactsPage />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>
And that's from Microsoft's official website. The Master Page in above is actually just one ContentPage, however, the Detail page should be NavigationPage, that one I can understand because it makes sense.
However, in my Prism app, the MasterPage also has to be a NavigaionPage, why is that? Any one can help on this?
Thanks.
You can take a look at this wonderfull blog about How to make Master-Detail Page Navigation menu in Xamarin Forms with Prism.
If you scroll down to the bottom of the post, you will see some description on why it works this way, Quoting:
Note: Navigation in Prism is all based on this url format where we can define to which pages we want to go, and it can be something like this: ViewA/ViewB/ViewC/ViewD
... and if you remember we are inside of MasterDetail page so navigating from MasterDetail will get result that those pages will go to Detail part of it... and that is great for us, we have menu in side of master page and choosing menu items will open pages as Detail pages.
The way that Prism Navigation is designed, it makes sense that a DetaiPage goes inside the MasterDetail, so basically it keeps the Prism Logic of doing the Navigation.
Quoting the Basics of Prism Navigation
Navigating in a Prism application is conceptually different than standard navigation in Xamarin.Forms. While Xamarin.Forms navigation relies on a Page class instance to navigate, Prism removes all dependencies on Page types to achieve loosely coupled navigation from within a ViewModel. In Prism, the concept of navigating to a View or navigating to a ViewModel does not exist. Instead, you simply navigate to an experience, or a unique identifier, which represents the target view you wish to navigate to in your application.

How to disable (make inactive/grey out) File button in MS Office document

I try to disable File button in MS Word.
example
I know that we can disable backstage using customUI.xml:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<backstage>
<button idMso="FileSave" visible="false"/>
<button idMso="FileSaveAs" visible="false"/>
<button idMso="FileOpen" visible="false"/>
<button idMso="FileClose" visible="false"/>
<button idMso="ApplicationOptionsDialog" visible="false"/>
...
</backstage>
</customUI>
But i need to fully disable button. User should have no abilities even click it. I must hide backstage from users. I saw similar question. This has 1 answer which says
It's not possible to hide this button
Also, Edraw library has such possibility link. Someone has any thought?
Hiding the File tab requires you to hide the default ribbon:
<CustomUI xmlns="http://schemas.microsoft.com/office/2009/07/CustomUI"> <ribbon startFromScratch="true"/></CustomUI>
Then replace it with a new ribbon that you design from scratch.

How to navigate from detail page to second master page SAPUI5

I have 2 master pages & a detail page. On Master 1 page, I have List items, On clicking one, it will navigate to 2nd Master page. There i have some selections & a button to navigate to detail page. I tried to navigate from detail page to 2nd Master page. But i can't make it. I goes straight to 1st Master Page. How can i achieve this?. Here is my view structure.
<SplitApp id="MyApp" mode="HideMode" >
<masterPages>
<Page id="master1">
<content>
....(List item)....
</content>
</Page>
<Page id="master2">
<content>
....(contents in fragment)....
</content>
</Page>
</masterPages>
<detailPages title="Detail">
<mvc:XMLView viewName="demo.view.Detail"/>
</detailPages>
</SplitApp>
You should make a reference to your app control, and using its method .toMaster(target) you could navigate to any master page, including 'master2'. E.g.:
this.byId("MyApp").toMaster(this.createId("master2"));
Have a look at this jsbin to see this in action:
http://jsbin.com/xocavo/1/edit?html,output

How do you modify Sitefinity's breadcrumb control?

I need to modify sitefinity's breadcrumbs from this:
Home
to this:
Home >
So if the breadcrumb is on the root page, it needs to have the > after it.
Im an absolute beginner, so go easy on me! (using version 3.7)
Regards
Peter
I had a similar problem in the past and solved it by creating a custom user control with the breadcrumb control embedded within it. this allows you to add your own custom logic in the code behind to show or hide things as necessary:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="BreadcrumbControl.ascx.cs" Inherits="UserControls_Internal_BreadcrumbControl" %>
<%# Register TagPrefix="sfweb" Namespace="Telerik.Cms.Web.UI" Assembly="Telerik.Cms.Web.UI" %>
<asp:HyperLink ID="lnkHome" runat="server" NavigateUrl="/" Text="My Home Page" /> »
<sfweb:Breadcrumb ID="bCrumb" runat="server" PathSeparator=" » " />
here you can hide the BreadCrumb on the home page, showing the homepage hyperlink, which you can customize to show whatever you need.
There may be a better way to do this, but this was the fastest, easiest way I could figure out to do it.
hope this was helpful!
You can easily change the mockup separator. You need to edit the Breadcrumb, click on the advanced button and find the NodeSeparatorMarkup field.
In my case I've put >> instead of >
<span class='sfBreadcrumbNodeSeparator'>»</span>;