Why NavigationPage.SetBackButtonTitle do not use? - xamarin.forms

I have three Page(A,B,C) in my xamarin.forms project.I have a need that A push B,B puch C,When B push C,I want Set C page's Back Button'title to be other title.I use the method:
CPage cpage = new CPage();
NavicationPage.SetHasBackButton(cpage,true);
NavicationPage.SetBackButtonTitle(cpage,"A Page");
Navication.PushAsync(cpage);
But the C Page's BackButton' Title is also "B Page".Why?
B Page View
C Page View

The SetBackButtonTitle method is a bit unintuitive. If you want to set the title for C Page, you have to call SetBackButton title on B Page (the previous page)
In B Page constructor, after InitializeComponent, call SetBackButtonTitle
public BPage()
{
InitializeComponent();
SetBackButtonTitle(this, "Back Title");
}
and push the C Page normally as you would
Navigation.PushAsync(cpage);
this means, any page pushed from B Page will have the back button as "Back Title"

Change the title for iOS, the title use in any other page or the title is the same as class name. try to change the title of the page, its work for me.

Related

How can I create a name prompt before page loads and add its content to iframe src on the same page?

I have this page on my website:
https://www.lior.vip/chat
When this page loads, there is an iframe in the center of the page that runs video chat system that works like zoom.
Before the page loads, I want a popup to appear that asks the user to enter his name with two buttons: "ok / continue without name"
When user enters his name and hits "ok",
I want this name to be added to the iframe src.
For example,
if the iframe src is: "https://www.videoconf.com/room1"
I want the source to be: "https://www.videoconf.com/room1/displayName=what user entered at name prompt.
And if user hitted "continue without name",
I want the iframe src stay the regular (https://www.videoconf.com/room1).
How can I do it?
The most simple way is use prompt comand. For example, you can write this code right after body tag in your page.
<script>
let displayName = "";
const namePrompt = prompt("If you want to enter anonymous you can click 'Cancel' button, else insert your name here:");
if (namePrompt !== null) {
displayName = "/displayName="+namePrompt;
}
document.getElementById("Iframe Id").src = "your url source"+displayName;
</script>
If you prefer you can create dinamically a popup window with javascript. Or put the code inside a function and get the name as return value.

Xamarin Forms Tabbed Page to have overlapping Custom View

I need to have something like that with XF Tabbed Page:
I.e., I need some panel which would appear over the whole content (including any tabs) where I can add some custom content. (The reason why I am asking it here, as it wouldn't be an issue in case of common simple page, when I would just have some overlapping view placed on the page).
In functionality it should be something like Action Sheets, but be cross-platform (i.e., defined as common XF view) and include custom content.
But it must be not necessary custom renderers with actually Action Sheet implementation (and AlertDialog accordingly to this). It would be perfect to have some view placed somewhere (I don't know where) in the page layout structure to achieve this.
Or Action Sheet and AlertDialog (with custom renderers) are still the easiest way to have it these days in XF? Thanks!
You can use ACR User Dialogs, and you can specify the UseBottomSheet option to make the action sheet appear at the bottom. Its available as a NuGet package, so there is no need for any custom renderers.
Acr.UserDialogs.ActionSheetConfig = new Acr.UserDialogs.ActionSheetConfig();
config.UseBottomSheet = true;
config.Title = "My Options";
config.Add(
"Option 1",
() =>
{
Device.BeginInvokeOnMainThread(async () => {
await DisplayAlert("", "Clicked option 1", "OK");
});
},
null);
config.Cancel = new Acr.UserDialogs.ActionSheetOption("Cancel");
And to display it:
Acr.UserDialogs.UserDialogs.Instance.ActionSheet(config);

Xamarin Forms - How to do navigation without return

I have two pages: Page A and Page B. I want that the user on my application be able to pass since page A to page B, but I don,t want he to be able to pass since page B to page A. How can I do that?
I tryed to use Navigation Page and deactivate the return Button, but I couldn't find how deactivate it.
If you don't need to "Navigate" you can set
Application.Current.MainPage = new PageB();
and override OnBackButtonPressed()
protected override void OnDisappearing()
{
//back button logic here
return true;
}

Why does the tabbar items label change when Pushing using UINavigationController?

I created UITabController with three tabs. One Tab has UINavigationController that pushes three controllers A,B, &C.
When I push segue from A to B or B to C, I change the titles on A, B, &C. Changing the title on A, B or C also changes the title of my third tab item in the main tabController. How can I make the tab bar items labels on the main Controller fixed?
I had the same problem and this thread fixed my problem: self.title sets navigationController and tabBarItem's title? Why?
You basically need to set your title in your viewDidLoad method in your UIViewController (which is displayed by the UINavigationController) like this:
self.navigationItem.title = #"Your Title";
instead of this
self.title = #"Your Title";

Problem regarding master pages

I have a simple master page (master.aspx), which has 3 link buttons namely HomeLBTn-which redirects the users to home.aspx, LoginLBtn-to login.aspx, RegisterLBtn-to Register.aspx
Every page in my project inherits the master page. And home.aspx also inherits the master.aspx, but i don't want the home.aspx to inherit the HomeLBtn, I want it to inherit the remaining 2 LBtn's, but not the HomeLBtn. How can i incorporate this condition into Home.aspx
Please help me
Thanks in anticipation
One way would be to find the control in the MasterPage and set its visibility to false:
Page.Master.FindControl("HomeLBtn").Visible = False
This would be done in the Page_Load (or some other lifecycle event) on the page that shouldn't show the Home button.
In master.aspx, define Register and Login link buttons, and a content placeholder for where the Home button would go. Then have Home.aspx inherit master.aspx. Then create a 2nd master page (master2.aspx) that inherits from master.aspx. In master2, add the Home link button in the content placeholder, and have your other pages inherit from master2.
You can do something like this in the master page ( Check what the child page is )
//If the child page is viewing an order then disable the new request button
if (this.ContentPlaceHolder1.Page is OrderView)
{
base.RemoveMenuItem("New Request", mnuSettings);
}
Note: base.RemoveMenuItem is a method of my base page
http://wraithnath.blogspot.com/2010/09/how-to-hide-show-controls-on-master.html
Another option would be to add a property to the child page and master page and use session data to hide and show buttons.
eg. in Child Page:
protected MyCustomMasterPage CustomMasterPage
{
get
{
return this.Master as MyCustomMasterPage;
}
}
In your master page you could have a session variable you can set to hide and show the buttons
public bool HomeVisible
{
get
{
return (bool) Session["HomeVisible"];
}
set
{
Session["HomeVisible"] = value;
}
}
You would then check the HomeVisible property when loading the master page to show / hide the button. You can then set this from the child page.
this.MyCustomMasterPage.HomeVisible = false;
Maybe not the best ways but they work

Resources