Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 91519 articles
Browse latest View live

Bad location Google Maps Xamarin Forms (Middle of the ocean)

$
0
0

I'm using Xamarin.forms.Maps and ExtendedMap, I did make a custom control, here I can get the location when the user tap on map but by default the map position is in the middle of the occean, something like this 0.0756931, 0.0786793. I was seaching and trying for a while but I did not find the solution.

I did see that the map is loading the region.LatitudeDegrees and region.LongitudeDegrees but I really don't why is this happen,

Xamarin.Forms 3.0.0.482510
Xamarin.Forms.Maps 3.0.0.482510
Xamarin.Plugin.ExternalMaps 4.0.1

MapGoogleView.xaml

<local:ExtendedMap 
                WidthRequest="320" HeightRequest="200"
                x:Name="MyMap"  Tap="OnTap"
                IsShowingUser="true"
                MapType="Street"/>

MapGoogleView.xaml.cs

public MapGoogleView(double lat, double lon)
        {

                InitializeComponent();
                NavigationPage.SetHasNavigationBar(this, false);

                var map = new ExtendedMap(
                    MapSpan.FromCenterAndRadius(
                        new Position(lat, lon), Distance.FromMiles(0.3)))
                {
                    IsShowingUser = true,
                    HeightRequest = 100,
                    WidthRequest = 900,
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    MapType = MapType.Street
                };
 var stack = new StackLayout { Spacing = 0 };
                stack.Children.Add(map);
                Content = stack;

var position = new Position(lat, lon); // Latitude, Longitude
                var pin = new Pin
                {
                    Type = PinType.Generic,
                    Position = position,
                    Label = "Ubicación",
                    Address = "Latitud: " + lat.ToString() + ", Longitud: " + lon.ToString(),
                };
                MyMap.Pins.Add(pin);
                map.MoveToRegion(
                MapSpan.FromCenterAndRadius(
                new Position(lat, lon), Distance.FromMiles(1)));
}

ExtendedMap.cs

public class ExtendedMap : Map
    {
        public event EventHandler<TapEventArgs> Tap;

        public ExtendedMap()
        {

        }

        public ExtendedMap(MapSpan region) : base(region)
        {

        }

        public void OnTap(Position coordinate)
        {
            OnTap(new TapEventArgs { Position = coordinate });
        }

public async void OnTap(Position coordinate)
        {
            try
            {

                    OnTap(new TapEventArgs { Position = coordinate });
            }
            catch (Exception error)
            {

                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    error.Message,
                    "Aceptar");

                return;
            }
        }

        protected virtual void OnTap(TapEventArgs e)
        {
            var handler = Tap;
            if (handler != null) handler(this, e);
        }
    }

    public class TapEventArgs : EventArgs
    {
        public Position Position { get; set; }
    }
}

Droid
ExtendedMapRenderer.cs

public class ExtendedMapRenderer : MapRenderer, IOnMapReadyCallback
    {
        private GoogleMap _map;



        public void OnMapReady(GoogleMap googleMap)
        {
            _map = googleMap;
            if (_map != null)
                //_map.GestureRecognizer.Add(new);
                _map.MapClick += googleMap_MapClick;
        }

        public ExtendedMapRenderer()
        {

        }
        protected override void OnElementChanged(ElementChangedEventArgs<Map> e) //cambiar a xamarin.forms.view
        {
            if (_map != null)
                _map.MapClick -= googleMap_MapClick;
            base.OnElementChanged(e);
            if (Control != null)
                ((MapView)Control).GetMapAsync(this);
        }

        private void googleMap_MapClick(object sender, GoogleMap.MapClickEventArgs e)
        {

            ((ExtendedMap)Element).OnTap(new Position(e.Point.Latitude, e.Point.Longitude));
        }


    }

I need the map can be centered on my position, I am get the position using Xam.Plugin.Geolocator

Thanks in advance.


Listview Issue

$
0
0

Hello i am now having a problem with my listview
this is what were trying to achieve

but i get stuck because i have no idea how i can like cut viewcells and place them next to eachother.

            <ListView.ItemTemplate>

                <DataTemplate>

                    <ViewCell>

                        <StackLayout>

                            <StackLayout HorizontalOptions=" VerticalOptions=" HeightRequest=" WidthRequest="100">

                                <Image Source="{Binding ImageNaam}"
                                       Aspect="AspectFit"/>
                            </StackLayout>

                            <Label Text="{Binding GerechtNaam}"
                                   TextColor="Black"
                                   FontAttributes="Bold"
                                   HorizontalOptions="Center"
                                   VerticalOptions="Start"/>

                        </StackLayout>

                    </ViewCell>

                </DataTemplate>

            </ListView.ItemTemplate>

        </ListView>

Picker popup is shown twice when calling focus()

$
0
0

Hello

I've an issue when a Picker (in my example an ExtendedPicker, but it also happens with a normal Picker). In some cases (see below), when calling Picker's focus() method, the popup opens twice in Android simulator (not sure about iOS/real device).

In my case I've got a ListView with a Picker on each item. They work as long as I don't delete an item. After I deleted an item, on some still existing items when opening Picker, it's opened twice.

To reproduce the problem, you can load the project from here: https://github.com/skurth/App1

1) Start app
2) Delete group "Tübach City" by pressing "Delete" button next to it.
3) Press on one of the three "Kopf" buttons from group "PSW Tübach" (not from group "1. FC Schwangere Bergente", there still one popup opens correctly). They open a picker.
4) Press OK on the opened Picker.
5) Another picker popup is shown. Why?

Is there something I do wrong or is it a bug?
Relevant code is in file "ItemCell.cs", starting from line 39.

(The reason why I set picker IsVisble=false and using a button instead of the standard picker label is because I need to customize font etc., and this way it's easier than writing a custom renderer for Picker.)

Custom Stepper with 2 buttons and Entry

$
0
0

Hi ,
I used stepper but since i couldn't change it's seize now I have to replace it by 2 buttons .

Is there any sample like that ? working just like stepper ?

ListView binding to ObservableCollection does not update GUI

$
0
0

Hi

Can anyone tell me why this simple code is not working as expected? Does the ListView control not listen for changes in the bound property?

  • Expected: when I click the Add button, the GUI (ListView) updates through the binding and shows the new element in the ObservableCollection.
  • Observed: GUI does not update but always shows the initial three items of the ObservableCollection.
  • Btw: OnAddButtonClicked() does get called and ListViewItems does get updated (checked in the debugger). Calling OnPropertyChanged("ListViewItems") inside OnAddButtonClicked() did not help either.
  • And: if I update the code as follows, the ListView works: add a Label control, bind that label to a 2nd property, update that property inside OnAddButtonClicked(), call OnPropertyChanged() from inside the property setter. So obviously this call to OnPropertyChanged() somehow triggers the ListView to get updated as well...
  • I'm now using Xamarin.Forms version 1.1.0.6201. Didn't work with the previous version either.

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"
             x:Class="Test1.MainPage"
             Padding="10" Title="MainPageXaml">
    <StackLayout VerticalOptions="StartAndExpand" HorizontalOptions="Fill">
        <Button Text="Add" Clicked="OnAddButtonClicked" />
        <ListView ItemsSource="{Binding ListViewItems}" />
    </StackLayout>
</ContentPage>

C#:

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        ListViewItems = new ObservableCollection<string> { "one", "two", "three" };
        BindingContext = this;
    }

    private void OnAddButtonClicked(object sender, EventArgs e)
    {
        ListViewItems.Add(DateTime.Now.ToString());
        // OnPropertyChanged("ListViewItems");
    }

    public ObservableCollection<string> ListViewItems { get; set; }
}

Markus

How to disable Home button click on some page in Xamarin.Forms

$
0
0

Hi,

Is there a way to disable home button click on particular page in xamarin forms.

Thanks.

My app command bar changed its color for no good reason

$
0
0

A strange thing happened to my application. The main window command bar (the one with minimize and maximize buttons) from common gray became black. The buttons stayed gray. I don't think I did anything to cause this.
Could you please give me any idea what did this and how to change this back?

What is the best way to design in Xamarin

$
0
0

I need to design Xamarin app screen. What is the best way for this. Any Suggestions Please


how to accept rich content(Gifs/stickers) in Entry or Editor from keyboard

Integrate Stripe SDK for xamarin forms

$
0
0



Hello Developer,
How developers how can integrate Stripe Api and Stripe SDK for android and IOS.

I read this post "https://stripe.com/docs/mobile/android".

I have "build.gradle" but i can't add this file in inside the dependencies section.

Below I attach build.gradle and dependencies section.

Help for Integrate Sprite payment gatway in xamarin forms.

Thanks

Deepak :smile:

In Xamarin forms -> Android App, there is any way to call Python script?

$
0
0

Hi, I'm building an Xamarin Forms solution to create a mobile application, for now we are targeting Android, my boss ask me to include (package) an existing python code to be used by this mobile application, this python code do some specific treatments, basically the mobile application send command to python to execute some python scripts, and get the result from text file in local drive.
Since a few days, I'm trying lots of things without success.
I like to know if it's possible to Xamarin Forms (Adroid App) to call Python scripts?
Thank you!

Making use of the APK

$
0
0

Hi All,

Thanks again for all the past help... so now the app is built the icons are set... and the APK is made... (will be trying this for what seems to be a very complicated apple process very soon as I think I understand what xamarin is attempting... but to be honest... I will admit I don't understand the apple deployment process... we have a dev account but I am guessing I need to copy and paste my source code to visual studio on the mac?)

Any way this question is about installing the apk... currently two devices they I have tried here at the company to install the APK on the apk fails to install.
I am guessing I am not understanding the xamarin target framework option and the the min android version...

THe app is built with targeted frame work set at api 27... with the min android version at api 23 so and droid 8.1 thru 6.0....
I am guessing that the min android option is for show?

My users have android 8.0 on their devices so I thought that range would allow them to install and use the apk...

So far on the devices I have tried to install the apk on they have failed... the only device I can install the apk on is the android emulator I have on the development windows machine I made the application on...

When I selected adhoc on the archive from visual studio and gave it a signing password and all of that stuff...
but on the users devices the apk will not install..

Do I need to step down the target frame work and rewrite this basic app to work on each level of android so for example.. set target frame work and write a xamarin forms for that api level and step down and write on for android 6?

Will I need to do some similar for the apple products as well?

Thanks again guys

Max length on Entry

$
0
0

Is there a way to limit the length of text in an Entry control? If not, is it planned to add this feature?

localisation for string Format

$
0
0

Hi, I want to do localisation for below code , not able to find out , I want to translate it in Chineese and portuguese
can anybody help e with this.Thanks in advance

<Label Text="{Binding UpdatedAt, StringFormat='Last Updated : {0:dd-MMM-yyyy} '}"

Button text inside a Grouped Listview header is not binding to group property.

$
0
0

Hi I am trying to dynamically changed the button text inside Groupheader in GroupListview but its always empty. Below is the code snippet.

                      <Button  Grid.Row="0" Grid.Column="3" Text="{Binding **ButonText**}" WidthRequest="175" 
                                      BackgroundColor="White" 
                                      Command="{Binding AddImages}" 
                                      CommandParameter="{Binding Source={x:Reference Item}, Path=BindingContext}"
                                      BindingContext="{Binding Source={x:Reference GroupedView},Path=BindingContext}"      />  

But when i remove the binding Context from Button than Text is displayed properly but than Command does not work.

Thanks in Advance.


I knew this was going to happen.. I broke my application use to work in Android now it does not. :(

$
0
0

I was dreading this...

I worked all day today to get this application to run on an apple meaning getting the dev account info and getting the application to run via a connected Macintosh computer get a device registered and all the other apple hoops you have to jump through... and now my xamarin application for that worked great in Android will not compile...

I get the following errors now:

Severity Code Description Project Path File Line Source Suppression State
Error ADB0020: The package does not support the CPU architecture of this device.
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\21\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 337
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.b__0(Task1 t) in E:\A\_work\21\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753 at System.Threading.Tasks.ContinuationTaskFromResultTask1.InnerInvoke()
at System.Threading.Tasks.Task.Execute() 0 Build

So now I cant get it to run on the Android emulator...

Let me ask you all what is the best practices here...

Should I Just creat two visual studio projects and have one setup for the apple and one set up for the Android...

I guess my only bet now is to pull and old version from source control...

THanks for any advice...sorry so many questions... but this experience with xamarin has been a horror show and I just want it to end.

Adding TextChanged event to an Entry view is crashing whole XAML?

$
0
0

If I remove the event, all is well. Any explanation? Any resolution?

Not able to install ipa in iphone, It stuck with "Installing"

$
0
0

Hi,I have once installed ipa in iphone with AdHoc distribution , it was working fine.After one day I have changed the provisioning profile and again created the ipa , now it is not installing in iphone and in itunes I am stuck with "Installing".I have read issues here about this topic but that didn't help me. What can be the solution ?

How can I make a border around a selected item?

$
0
0

Dear experts,

I have a ListView with only two items it it. I need to make a border appear around the selected item. How can I do this?
Here is my code:

        <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell Height="100">
                        <StackLayout BackgroundColor="{StaticResource LogoBackgroundColor}"
                                Padding="15,10" 
                                Orientation="Horizontal" 
                                HorizontalOptions="FillAndExpand">
                            <Image WidthRequest="50" Source="{Binding IconSource}" Margin="10, 0" />
                            <Label VerticalOptions="FillAndExpand" 
                                VerticalTextAlignment="Center" 
                                Text="{Binding Title}" 
                                TextColor="White"
                                FontSize="24"/>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>

Thanks!

Azure App Services Mobile offline sync files

$
0
0

Hello everyone!

I'm developing a Xamarin.Forms app that is to be used primarily offline (it is a requirement). I manage to make sync work with azure using IMobileSyncClient and now was looking into a way to sync pictures to Azure BLOB Storage. I've searched high and low but couldn't find nothing that helpful.

The closest thing was a couple of articles that relied on Microsoft.Azure.Mobile.Server.Files nuget package, which is now retired. Right now I'm at a loss here.

I thought of doing it ad-hoc, managing everything by myself, piggybacking on the push methods on the client, but it sounds a lot of work, prone to errors...

Anyone else with same issue and with any valid approach? Thanks!

Viewing all 91519 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>