.Net MAUI - Shell Navigation Back Button Title (iOS) - ios

I have noticed one issue in Shell Navigation title. When setting ContentPage's Title property it shows same text with Back button also. Used NavigationPage.BackButtonTitle property as well from xaml still its not working.
For Example:
HomePage.xaml
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Switch_Bug.HomePage"
NavigationPage.BackButtonTitle="Back"
Title="Home Page">
<VerticalStackLayout>
<Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>
Result:
Expected result:
In iOS, it should Back Button text as "Back" otherwise just show the back button. But it shows the page's title text.
Update 02/02/2023
The main issue is if the title of the page is short then it will show the same with the back button and if the title is long enough then it will work fine.
The same issue was reported on the MAUI git repo as well. https://github.com/dotnet/maui/issues/11691

First of all, I believe BackButtonTitle will only work for iOS since Android does not use "back titles"
Second, the BackButtonTitle might be slightly counterintuitive, but it is the title that will be displayed on a further page that navigates back to the page you defined in on. In your case, setting the BackButtonTitle on your HomePage to "back" does not set the back button on the HomePage to "back"; it will set the back button to "back" on any page that has a back navigation to the HomePage. Hope that makes sense.

NavigationPage.BackButtonTitle is applicable to Navigation.PushAsync in NavigationPage, but not in Shell. There is a corresponding method in Shell’s navigation to change the text of the back button. I did a simple test, and you can modify your code as follows:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Switch_Bug.HomePage"
Title="Home Page">
<VerticalStackLayout>
<Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
<Shell.BackButtonBehavior>
<BackButtonBehavior TextOverride="Back" />
</Shell.BackButtonBehavior>
</ContentPage>
For more details, you can refer to the official documentation:.NET MAUI Shell navigation

Related

MasterDetail page Master behaviour change not working in iPhone devices.How to Change it to popover?

MasterDetail page Master behaviour change not working in iPhone devices. it always showing the master page below the detail page while sliding. I need master page slide above the detail page.
<MasterDetailPage
x:Class="testMasterDetail.Views.MainPage"
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:views="clr-namespace:testMasterDetail.Views"
MasterBehavior="Popover"
mc:Ignorable="d">
<MasterDetailPage.Master>
<views:MenuPage />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
<NavigationPage.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS" Value="tab_feed.png" />
</OnPlatform>
</NavigationPage.Icon>
<x:Arguments>
<views:ItemsPage />
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
That's the default behavior in iOS and the MasterBehavior does not have any influence on an iPhone. It works in an iPad.
There is already an issue there in GitHub of Xamarin.forms. You can follow it and add some comments to ask for more information.
Here are some thread which may help: xamarin-forms-slide-up-master-detail-page and Master-detail menu - slide over top of detail page on iOS

Xamarin toolbar item on IOS not aligning properly

I am having difficulty in aligning a toolbar item to the far right on the IOS build of a Xamarin application, although, on the Android build, it works perfectly fine and aligns the toolbar item to the far right of the toolbar.
XML code for the toolbar item:
<ContentPage.ToolbarItems x:Uid="ToolbarName">
<ToolbarItem x:Name="Settings" Order="Primary" Icon="cog.png" Priority="0" Clicked="Settings_Clicked" />
</ContentPage.ToolbarItems>
IOS build toolbar:
I do not want to change the XML too much as I am worried that it will then effect the android build.
Any help on the matter would be greatly appreciated.
Thanks.
This is a known issue of the Xamarin ToolbarItems, you could try update you Xamarin Forms version to see if the issue was fixed.
A workaround would be using a NavigationPage.TitleView (source)
<ContentPage>
<NavigationPage.TitleView>
<StackLayout Orientation="Horizontal" VerticalOptions="End" Spacing="10" HorizontalOptions="End">
<Image Source="cog.png">
</Image>
</StackLayout>
</NavigationPage.TitleView>
</ContentPage>

Xamarin.Forms Popup Dialog with custom view

I am trying to implement Popup dialog or Dialog in Xamarin.Forms but i am unable to find any reference or document to achieve this.
I want to show view on top of current page, something like this...
Currently i am focusing on iOS in Xamarin.Forms... Any code snippet or project reference is appreciated
Popup Page Plugin for Xamarin Forms
The plugin allows you to open any page as a popup.
Nuget: https://www.nuget.org/packages/Rg.Plugins.Popup/
Unfortunately you can't Push to the ModalStack because it replaces the current page and you want to see the current page underneath.
So you have a few options here of create your own if you want complete customization or use a package such as: https://github.com/aritchie/userdialogs. They have a link to examples on that page.
Here is a quick customizable one if you want to roll your own.
<Grid IsVisible={Binding IsDialogShown}" BackgroundColor="Black" Opacity="0.7">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="500" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackLayout Grid.Row="1">
.. Controls in here (change this to grid or whatever you want)
</StackLayout>
</Grid>
You can take a look to popup layout in Xamarin Labs
https://forums.xamarin.com/discussion/32373/how-to-implement-a-pop-up-window-in-xamarin-forms
FormsPopup can do the trick using Xamarin Forms
We can achieve dialog like interface using PopupLayout
https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/src/Forms/XLabs.Forms/Controls/PopupLayout.cs
How to use :
http://forums.xamarin.com/discussion/comment/101489/#Comment_101489

How to enable or disable the buttons in windows phone 7?

My Design has the following lines of code:
<Button BorderThickness="0" Content="Done" FontSize="21.333" Height="65" Margin="334,13,6,0" VerticalAlignment="Top" FontFamily="Times New Roman" Name="btnConvert" >
<Button.Background>
<ImageBrush ImageSource="Images/button_back2.png" />
</Button.Background>
</Button>
My code goes btnConvert.IsEnabled = false;.
It can't disable the button. Instead, it hides the button. I need that button to be visible but disabled. Please help me.
Isenabled works for me. try your xaml code in some xaml viewer to check if you are not doing anything wrong
This is what I usually do:
`btnConvert.IsHitTestVisible = false;`
It will disable the button, but you can see the button with the same colors at beginning.

XUL Textbox inside Popup not working

I am working on creating a Firefox extension. I have added a textbox inside a popup. The popup opens on clicking on a toolbar button. The textbox is appearing but does not let me edit it. I have not given any read only attributes.
Here is the code:
<popupset id="myPopupSet">
<popup id="trial-popup" noautohide="true" position="after_start">
<vbox>
<label value="Enter your name:"/>
<textbox id="identfier_box" value="This is some text."/>
</vbox>
</popup>
</popupset>
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="mybutton"
class="toolbarbutton-1"
label="Identifier"
popup="trial-popup"
insertbefore="urlbar-container" />
can anyone let me know why there is this problem?
Thanks!
What you really want is a panel and not a popup.
Change <popup> to <panel> and you have what you want.

Resources