how to remove multiple back button from navigation in xamarin? - xamarin

please help me to sort out following issue.
this is my issue.if push without animation(false)then issue.if animation true then working fine.
// await Navigation.PushAsync<DeleteDealsAndOffersViewModel>(); --> **working fine**
// await Navigation.PushAsync(new DeleteDealsAndOffersViewModel());**working fine**
vm = new DeleteDealsAndOffersViewModel
{
DealsAndOffersList = dealLists,
//CategoryColor = CategoryColor,
IsDelete = true
};
//await Navigation.PushAsync(vm,false); **issue with back button**
I have used following code for back button.this is my base class.
<?xml version="1.0" encoding="UTF-8"?>
<v:ExtendedContentPage
xmlns:v="clr-namespace:Core.Views;assembly=Core"
xmlns="http://xamarin.com/schemas/2014/forms"
LeftBarButtonTitle="< Back"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Vi.Views.BasicV">
<ContentPage.Content>
</ContentPage.Content>
</v:ExtendedContentPage>
now I create another page and set base class on that page
DeleteDealsAndOffersListPage.xaml
<?xml version="1.0" encoding="UTF-8"?>
<view:BasicV
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:view="clr-namespace:Vi.Views;assembly=FlagSpree"
xmlns:sty="clr-namespace:VillageVesl.Styles;assembly=FlagSpree"
xmlns:v="clr-namespace:Core.Views;assembly=Core"
xmlns:comp="clr-namespace:VillageVesl.Views.Components;assembly=FlagSpree"
x:Name="main" Title="{Binding Title}"
LeftBarButtonTitle="Cancel"
BackgroundColor="{x:Static sty:Colors.BGColor}"
x:Class="Vi.Views.DeleteDealsAndOffersListPage">
<ContentPage.ToolbarItems>
<ToolbarItem IsDestructive="true" Text="Delete" Command="{Binding DeleteAllSelectedDealsCommand}" />
</ContentPage.ToolbarItems>
<ContentPage.Content>
</ContentPage.Content>
</view:BasicV>
"DeleteDealsAndOffersListPage.xaml.cs".
namespace Vi.Views
{
public partial class DeleteDealsAndOffersListPage : BasicV
{
public DeleteDealsAndOffersListPage()
{
InitializeComponent();
}
}
}
Now problem is that when I push on DeleteDealsAndOffersListPage then display two back button.

It looks like you are creating your own Back Button. Xamarin will add it's own back button to any page that you push onto a Navigation stack, is that the extra back button you are seeing? If so, before you do the push, add:
NavigationPage.SetHasBackButton(vm, false);

Related

Xamarin.Forms.Map is not working for UWP platform. How to make it work?

I'm trying to load street map using Xamarin.Forms.Map plugin in my project for UWP app. For that I have also get the token from MSDN. Here is what I have done:
MapePage.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:vm="clr-namespace:Map_POC.ViewModels"
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
xmlns:local="clr-namespace:Map_POC.CustomControls"
x:Class="Map_POC.Views.MapePage">
<ContentPage.BindingContext>
<vm:MapePageViewModel />
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<maps:Map
x:Name="MyMap"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
MapType="Street" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
MapePage.xaml.cs
public MapePage()
{
InitializeComponent();
Position position = new Position(-37.8141, 144.9633);
var pin = new Pin
{
Type = PinType.Place,
Position = position,
Label = "I'm a Pin",
};
MyMap.Pins.Add(pin);
MyMap.MoveToRegion(
MapSpan.FromCenterAndRadius(
position, Distance.FromMiles(1)));
}
MainPage.xaml.cs (In UWP Solution)
public sealed partial class MainPage
{
public MainPage()
{
this.InitializeComponent();
Xamarin.FormsMaps.Init(Keys.UWPMapToken);
Windows.Services.Maps.MapService.ServiceToken = Keys.UWPMapToken;
LoadApplication(new Map_POC.App());
}
}
Output: With hybrid map it shows map but not showing pin and locations properly.
Other thing apart from this it not works in offline mode, can we cache map for offline mode?
Can we draw a polygon and coordinates covered inside the polygon can be clicked individually or not?
Any help on this will be highly appreciated.

Navigation bar not displaying page title in Xamarin Forms

I have been unable to get a simple test working to display a title in the Navigation bar of my Xamarin forms app. I am providing my code below, basically when I set the title on the content page and wrap the content page in a navigation page, the navigation bar is not displaying the corresponding title from the content page.
App.cs
public partial class App : Application
{
public App()
{
InitializeComponent();
Current.MainPage = new NavigationPage(new Presentation.Views.SettingsDeviceUnitView());
}
}
ContentPage.cs
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SettingsDeviceUnitView : ContentPage
{
public SettingsDeviceUnitView()
{
InitializeComponent();
}
}
ContentPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage 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:Controls="clr-namespace:GFIApp.Presentation.Controls"
mc:Ignorable="d"
x:Class="TestApp.Presentation.Views.SettingsDeviceUnitView"
BackgroundColor="{StaticResource Key=ColorPrimary}"
Title="TestTitle">
<ContentPage.Content>
<Grid>
</Grid>
</ContentPage.Content>
</ContentPage>
Yet I see nothing in the navigation bar
Has anyone seen this behavior before or have any suggestions? Thank you!
Per FreakyAli's response I tested setting the navigation bar text color and I am now able to see the title. Thank you for the suggestion FreakyAli!
For reference, I added the following in my App.cs
NavigationPage nav = new NavigationPage(new Presentation.Views.SettingsDeviceUnitView());
nav.BarTextColor = Color.White;
Current.MainPage = nav;

Can I "include" a XAML file? [duplicate]

I am trying a new approach i.e. XAML to make application in xamarin.forms. At this time i am facing an issue to reuse my stack layout which is having a image and label. How i can reuse my layout in different pages using XAML.
You can actually define your custom component in a separate XAML file and then just link the component wherever you need it.
For example a label with image can be grouped together in a dedicated XAML file:
<?xml version="1.0" encoding="utf-8" ?>
<StackLayout xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="UserControls.ImageWithTitle"
VerticalOptions="Center" HorizontalOptions="Center" >
<Label HorizontalOptions="Center"
x:Name="TitleLabel" />
<Image Source="noimage.png" />
</StackLayout>
On the .cs file I've defined a binding for the TitleLabel
public string TitleName
{
get { return TitleLabel.Text; }
set { TitleLabel.Text = value; }
}
So when you include the component on another layout, you can assign the label value directly (or via a binding):
<usercontrols:ImageWithTitle TitleName="Home"/>

Wrapping an MPVolumeView inside 2 Stack Layouts (Xamarin.IOS)

I am creating a control based on a generic View that works with a custom renderer based on an iOS MPVolumeView, which is the simple control that allows you to select an alternate output route for audio in your app (i.e. Bluetooth Speaker). The code works just fine if I wrap inside a single stack layout, but not if it's inside two stack layouts. My XAML looks like this... very basic:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="DABApp.DabTestPage" xmlns:local="clr-namespace:DABApp;assembly=DABApp">
<ContentPage.Content>
<StackLayout VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand" BackgroundColor="Red">
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand" VerticalOptions="FillAndExpand">
<local:AudioOutputView />
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
And here's the guts of my custom renderer:
[assembly: ExportRenderer(typeof(AudioOutputView), typeof(iosAudioOutputViewRenderer))]
namespace DABApp.iOS
{
public class iosAudioOutputViewRenderer: ViewRenderer<AudioOutputView, UIView>
{
MPVolumeView view;
protected override void OnElementChanged(ElementChangedEventArgs<AudioOutputView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
view = new MPVolumeView()
{
ShowsRouteButton = true,
ShowsVolumeSlider = false,
};
SetNativeControl(view);
}
}
}
}
With this XAML and code, when I push the page onto the nav stack async, the page won't even show. If I remove one of the StackLayouts, it works fine.
I changed my IOS control in the CustomRenderer to a simple UILabel and this works fine... so it looks like it has something to do with putting the MPVolumeView inside 2 StackLayouts. I need to be able to do this because of the layout requirements of my app, and it doesn't make any sense why 1 StackLayout is fine, but 2 isn't, and only for this native control.
Any ideas?

Xamarin Forms Signature Pad

Can someone please guide me on how to use a signature pad on xamarin FORMS.
I have tried resources available online, but the dont work in my project.
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:acr="clr-namespace:Acr.XamForms.SignaturePad;assembly=Acr.XamForms.SignaturePad" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Checkin.Signature">
<ContentPage.Content>
<ScrollView>
<StackLayout>
<acr:SignaturePadView
x:Name="padView"
HeightRequest="320"
WidthRequest="240"
BackgroundColor="White"
CaptionText="Caption This"
CaptionTextColor="Black"
ClearText="Clear Me!"
ClearTextColor="Red"
PromptText="Prompt Here"
PromptTextColor="Red"
SignatureLineColor="Aqua"
StrokeColor="Black"
StrokeWidth="2"
/>
</StackLayout>
</ScrollView>
</ContentPage.Content>
Above is one of the codes I have used. A signature pad appears but doesent display anything when I draw on top of it.
This is how the Red Signature pad appears
try to install it on droid project too. that works for me
In the AppDelegate, paste the following code:
public static Type dummyt = typeof(SignaturePad.Forms.iOS.SignaturePadRenderer);
As shown below:
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public static Type dummyt = typeof(SignaturePad.Forms.iOS.SignaturePadRenderer);
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
The problem apparently is that some DLLs are not

Resources