change back icon in toolbar inside Xamarin FormsPage - xamarin

Using xamarin forms (PCL),
I searched a lot but Can not find the exact solution,
Can i change the back button in toolbar or at least should i be able to change its color and the title color as well?

I am not sure for changing back button, but I was changing back button and title color.
An example, in App.cs file OnStart method I set that LoginPage is first page with black title, on this way
MainPage = new NavigationPage(new LoginPage()) { BarTextColor = Color.Black };
Please try something like this, I have some other examples if this one doesn't work.

Related

Change Side-Menu Button/Link Text Colour Dynamically Xamarin.iOS

I'm using a Side Menu iOS (not my choice just by the way) and I stumbled upon an issue that can be seen in the following image:
If you look close enough in the above figure, the red rectangle is actually highlighting the text 'Menu' that used to open the side menu and it's barely visible. It's quite simply changing the navigation bar text color which doesn't seem to affect that color.
How do I change the default color that is appearing above?
The tint determines this color.
You can change it globally by settting
UINavigationBar.Appearance.TintColor
If you just want to change the color of the menu button in a specific ViewController . Add the following code in the method ViewWillAppear() of your ViewController
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
this.NavigationController.NavigationBar.TintColor = UIColor.FromRGB(xxx,xxx,xxx);
}
NavigationPage has a property called BarTextColor, on iOS devices, this property changes the colour of both the navigation bar text and the menu button text. The following solution might be a problem though if one would like to have separate colours for each of the latter:
MainPage = new NavigationPage(YourPage) { BarBackgroundColor = Color.FromHex(#SomeHex), BarTextColor = Color.Red};
BarTextColor = Color.Red produces the following output:

Xamarin.Forms MasterDetailPage with part of master visible on detail

I want to push (make visible) little part of master page to detail page like on pictures in links below. Is it possible in Xamarin.Forms?
Before swipe
After swipe
I'll be grateful for help.
Set
<ContentPage NavigationPage.HasNavigationBar="False">
Place a StackLayout or Grid that looks like the side menu shown in your image. Add a tap gesture recognizer to it.
slMenu.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(() => ShowSideMenu(masterPage)),
});
private void ShowSideMenu(MasterDetailPage masterPage)
{
masterPage.IsPresented = !masterPage.IsPresented;
}
This is possible, but requires quite some work, since you can't access the width of the MasterDetailView directly.
In another post (see How to set width for MasterDetailPage in xamarin forms ) I have described how to change the width of the MasterDetail view.
While implementing that, I came across a behaviour like you want to have, though for me it was an error.
Basically the steps would be
Implement a custom version of the MasterDetail view where you can set up a custom width
Change the width of the master view so it is a bit wider than it should be
Adapt the calculations when collapsing and expanding the view so that they don't collapse the entire width
For instance if your Master View gets a width of 340 and you want the last 40 to show, make sure that when being collapsed it "only" moves by 300

How can I change the color of the Navigation Bar < and word in iOS and Xamarin?

My application uses a tab page and when I push a new page then a back navigation arrow appears with a word to the right of it.
In iOS it's blue. How can I change the color of this arrow and the text with Xamarin Forms?
The color is tied to the BarTextColor of the NavigationPage.
You can change the text by setting the Title of each page, that is what is shown by default. You can also change this by setting it through the SetBackButtonTitle(Page, string) method.

How do I scroll back to top in Xamarin.Forms

I have a WebView control in RelativeLayout. Sometimes Html is longer then display, so user can 'scroll' to the bottom. I want to add a button that would scroll back to top of the screen. But I'm not able to find any proper way to do this.
This button would also float at the bottom, that's why I'm using relative layout.
WebView neither RelativeLayout have property where I could scroll to top in my code-behind.
Is there any way to implement this?
You could use the WebView.Eval method. It's very simple, something like this would do:
MyButton.Clicked += (sender, e) => { MyWebView.Eval("window.scrollTo(0, 0)"); };

AppBar in WP7.5 Panorama page

I'm currently developing a Windows Phone 7.5 app with a panorama page.
At the panorama page, I'm implementing an appbar to deal with several things in the app, such as displaying phone location in a Bing Map which is located in one of the panorama page items.
Now, I believe I have two options, but I don't know how they would work (if they even do work...):
Show only appbar icons relevant to current page/item
If you're not at the respective page/item, redirect to the page/item when clicking the appbar icon.
Would any of these actually work? Could I set an ID for each of the panorama items, and then make either 1 or 2 to work?
Thanks :)
Both are possible to accomplish.
For showing only the appbar icons relevent to the page you can use the Panorama.SelectionChanged Event:
var currentPanormaItem = ((Panorama)sender).SelectedItem
if(currentPanormaItem.Equals(firstPageItem))
{
// Set AppBar icons for first page
}
else if(currentPanormaItem.Equals(secondPageItem))
{
// Set AppBar icons for secondpage
}
If you know which panorama item is selected you can set the appbar icon accordingly.
Changing the selected item of a Panorama can be accomplished like this:
panoramaControl.DefaultItem = panoramaControl.Items[indexToSet];
Though changing the selected index of a Panorama is possible, I would advise using a Pivot control. With a Pivot control it is easier to keep track of the selected item and you get a nice animation when you programatically switch the selected page.

Resources