I have xamarin forms ios application,where I need to remove the back arrow in the navigation bar but the title should be displayed and when user clicks on on that back button title it should navigate to previous view.
I tried using `
NavigationPage.SetBackButtonTitle(this, "Cancel");
NavigationPage.SetHasBackButton(this, false);
But the back arrow is still displaying,is there any why to have only the text Cancel without <symbol?
I solved my issue by adding a custom renderer as follows
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
this.NavigationController.TopViewController.NavigationItem.LeftBarButtonItem =new UIBarButtonItem(“Cancel”, UIBarButtonItemStyle.Plain, (sender, args) => { });
}
In your AppDelegate.cs file, in the FinishedLaunching method add these lines:
UINavigationBar.Appearance.BackIndicatorImage = new UIImage();
UINavigationBar.Appearance.BackIndicatorTransitionMaskImage = new UIImage();
This will however, remove it for every page. If you want it for just one page I would suggest like EvZ already mentioned: use a modal page or find another way.
Another way is to set the above lines to null which will restore the normal arrow. But this would mean implementing a custom renderer, dependency service or similar.
Remove navigation-bar and use image/header on navigation place and write into image/Header into navigation title...
image onclick event into write back command
Related
Is there a way to set the ModalInPresentation value from Xamarin.Forms? I can set On<iOS>().SetModalPresentationStyle(UIModalPresentationStyle.FormSheet); on my ContentPage but I"m not able to prevent a dismiss of the page for specific cases as I would need it.
but I"m not able to prevent a dismiss of the page for specific cases as I would need it.
Generally,we can use ModalInPresentation = true; to prevernt the page be dismissed in page renderer.
public class CustomPageRenderer :PageRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
ModalInPresentation = true;
}
}
It works in Xamarin.iOS. However, it not works in Xamarin Forms now. I will check that where problem is.
I've uploaded a sample project here:
www.otherwise.com/ModalPresentation.zip
The MainPage just has a button that shows a modal panel via:
Navigation.PushModalAsync(new OTNavigationPage(new ModalPage()));
OTNavigationPage is a subclass of NavigationPage. I use it to set the modal presentation style:
On<iOS>().SetModalPresentationStyle(UIModalPresentationStyle.FormSheet);
There is also OTContentPage which exists only so I can have a native renderer to try to set the ModalInPresentation flag to true. I do this in a variety of places trying to find one that works. None do.
I expect setting ModalInPresentation = true should prevent the modal panel from being dismissed via swiping. It does not.
There is also a bug which I think the team knows of where swiping to dismiss corrupts the navigation stack. If I try to show the modal page again I get:
Warning: Attempt to present <Xamarin_Forms_Platform_iOS_ModalWrapper: 0x10782cc00> on <ModalPresentation_iOS_OTNavigationPageRenderer: 0x107128600> whose view is not in the window hierarchy!
This post talks about it: https://github.com/xamarin/Xamarin.Forms/issues/7364
I've been using the MasterPageDetail approach in creating a hamburger menu for my Xamarin Forms app. The menu itself works fine as taken from the Xamarin documentation https://developer.xamarin.com/samples/xamarin-forms/Navigation/MasterDetailPage/. What I noticed was that if I create a simple link to a page in one of my views, the hamburger menu and it's icon are replaced with a back button.
What I would like to know is how to create a link in a content page that will preseve my hamburger menu instead of showing a back button. Any link you click from the MasterPage takes you to the corrosponding view but you can still see the hamburger menu, if you click a link within one of the pages however you are taken to the page but with a back button instead. It's causing a very confusing navigational experience for my users.
The following code demonstrates how the manu is created in the hamburger menu just now.
public partial class MasterPage : ContentPage
{
public ListView ListView { get { return listView; } }
public MasterPage()
{
InitializeComponent();
//var master = new MasterPage();
var masterPageItems = new List<MasterPageItem>();
masterPageItems.Add(new MasterPageItem
{
Title = "Dashboard",
IconSource = "dashboard-icon-24.png",
TargetType = typeof(Dashboard)
});
listView.ItemsSource = masterPageItems;
}
So that works perfectly, you can navigate around and the hamburger menu is there all the time.
Within my view called 'dashboard' I added some link to hope to those same pages that are in my hamburger menu, I did so int he following way:
<Button Text="Information" Clicked="informationClick" />
The code for this is as follows:
private void informationClick(object sender, EventArgs e)
{
Navigation.PushAsync(new Information());
}
When you click on this link however you lose the hambuger menu and it's repalced with the back button instead. I want to preserve the hamburger menu, does anyone know how I can do this from my content page?
You must replace the "Detail" property of your MasterDetail page with a new NavigationPage containing the page you are linking.
Something like that:
(App.Current.MainPage as MasterDetailPage).Detail = new NavigationPage(new ContactsPage());
This is not really clean but it makes the idea.
I want to disable the back button text in Xamarin iOS,
along with the button itself. I already disabled the back button itself but the text is left.
Does anyone know of any way to disabling the text as well?
Thanks
You can accomplish this in two ways:
NavigationItem.SetHidesBackButton(true, false);
or
NavigationItem.BackBarButtonItem = null;
If you use the second solution, then you would have to recreate the button if you ever want to make it visible again.
With Navigation Page:-
NavigationPage.SetBackButtonTitle(this, ""); //Empty string as title
or hide the Back button with:
NavigationPage.SetHasBackButton(this, false);
I created basic vertical layout that work as side menu and now I want to place some buttons in it. Few of them gonna work as common side menu buttons, they just change page content so I want to mark that they are clicked in some way, how can I achive that? Or maybe there is better way?
As stated in the 5th version of Vaadin7 manual, you can attach an event listener to the Button.
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
// show the button has been clicked with a CSS class:
button.addStyleName("v-button-clicked");
}
});
Don’t forget to define the v-button-clicked class. Of course you’re free to add the class of your liking through the .addStyleName() method.
in my application I have some screens with focusable custom buttons, wich pushing another screens with another focusable custom buttons and so on. When I press blackberry's "back" button anter pushing 2-3 screens, it sometimes appear notification with message "Changes made", and options "save", "discard" and "cancel". Why is this? How can I avoid it? all I did is moved focus and pressed buttons.
you can avoid this overriding onclose() and setdirty(false).
public boolean onClose() {
setDirty(false);
return super.onClose();
}