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

Xamarin forms maps IOS key and Xamarin forms Map UWP Zoom keys not disabling

$
0
0

Hi

Sorry for odd questions but need to ask the question some where for clarification :(

So I am using Xamarin forms Maps within my PCL project for Android, Apple and Microsoft and in the notes on line I can see where to put the code to use the google maps API for Android but am not sure where to put it for the IOS version? But am Initialising as it says in the notes. Interestingly so far on test the iPhone still lets me access the map as well as UWP as I have not added the API key there either and so makes me wonder if access to the map on an iPhone and UWP is free or is it just using the same key somewhere that I use for the android? I ask the question as im worried that when I release it if I don't have the proper key on the iPhone or on UWP side then the map may not work but then I don't want to add the keys if it works any ways and don't want to get charged triple :(

Which makes me wonder if I actually need Google maps at all as I just want a map to show at the users location and phones do store their local users map data on the phone but sadly when I remove the Google key on the android side it does stop the map working for android only.

So im expecting an answer on the lines that yes your app will not display a map on iPhone or UWP unless you put in a key and for iPhone this is where you put it? which I assume is AppDelegate.cs and may be Xamarin.FormsMaps.Init("INSERT_AUTHENTICATION_TOKEN_HERE"); I suppose I just want clarification, just in case some one tell me I can do all this for free :)

My second question is that I have disabled zoom and scroll on my map as I don't want the end user to be able to move the map about and this works perfectly on Android and Apple but the UWP still zooms as there are zoom buttons on the right, see pic below, does any one have any thoughts to remove that I may have missed or could this be a bug perhaps. im thinking of creating a customer renderer for the map for UWP but seems unnecessary work if it works on Android and Apple

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/map/setup


Unit Tests and Visual Studio App Center Questions

$
0
0

Hello all I am currently working on an xamarin shell application. I do have data entry and I have tested that to no end. However most of our app is a blackbox...you put in information, goes into an algorithm and we spit back information. There is really no validation other than the information being sent in, and all that is validated.

My big question is, I have been look at Visual Studio App Center. I am going to release the Android version first. With the NUMERIOUS amount of Android devices out there, is there something out there that I can use, that will tell me if the layout is not right in a certain version? I am using some Syncfusion controls and I have had an abundance of issues with them from not working correctly on some devices, laying out different on some devices and so forth.

Lastly...can someone recommend a good set if unit tests and examples to use? I have tested saving the data so much that I am not sure if unit tests are even viable for that...I am am more worried about the layout and controls not working.

Any help for advice with this would be much appreciated.

Animated GIF Splash Screen using FFImageLoading

$
0
0

Hello,

I followed Microsoft Documentation to implement Splash Screen and it works very well.
I´m using FFimageLoading to display Gifs inside APP, and it works, but i don´t how to do it to play a Gif as Splash Screen...

Could you help me ?

Thanks in advance

Text Editing with Auto Suggest and Formatting

$
0
0

Hello all,

I could really use some help identifying an approach/control on this problem. I'm trying to implement something like is seen in Facebook or Instagram where one can type a friend/contact name, a list of suggestions appears, and then the user can select one to insert, that selection is added and appears differently than the other text. This doesn't seem like a huge ask but I cannot find anything close to it other than some completely custom solution.

Desired text example: Here is your Suggestion that was Selected.

I would be glad to hear any suggestions. Controls to start with to add the functionality to. Paid or open source packages. Keywords that I may not be aware of that describe the functionality I'm describing. Anything would be helpful.

Thanks!
Adam.g

How to make columns in ListView?

$
0
0

<ListView x:Name="listview" ItemsSource="{Binding MotorType}" SelectionMode="None" Margin="0" HeightRequest="220">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<CheckBox HorizontalOptions="Start" Color="Black" CheckedChanged="CheckBox_CheckedChanged" IsChecked="{Binding IsSelected}" />
<Label Text="{Binding Name}" TextColor="Gray"></Label>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

I have listview,please say how to make few columns(I do not to use collectionview) I have this

I want this

Creating and Consuming resources in C#

$
0
0

I am tansitioning to C# from XAML. I converter the xaml code in the app to C#. But stuck in using resources. The official documentation doesn't have any thing related to resources.
Specifically I want to use AppThemeBinding for the darkmode and lightmode colors in my C# content Page. As I am transitioning to C# I will only have App.cs file. So, I also want to replace previous XAML code where App Resources are defined with C#.

Unanticipated visual elements present in the raster image generated via its SVG counterpart

$
0
0

An unanticipated amount of dregs is present in the background of the PNG images (as seen in the following images) generated from their SVG counterpart (attached to the app as an embedded resource) using the SkiaSharp libraries for use in Button and ToolbarItem views.

At a cursory glance, I believe that the issue pertains to the way the PNG image is generated from the SVG but, as of now, am unable to isolate the portion causing this "improper conversion" as I cannot segregate the problematic portion in the implementation of the GetEquivalentBitmapImagePath() method (shown below).

Code that generates the above entity:

string calculationHistoryIcon = GetEquivalentBitmapImagePath
                          (CALCULATION_HISTORY_ICON_RESOURCE_IDENTIFIER,
                           80, 80);
ToolbarItem calculationHistoryToolbarItem = new ToolbarItem()
                { IconImageSource = calculationHistoryIcon };
this.ToolbarItems.Add(calculationHistoryToolbarItem);

Code that generates the above entity:

string fullKeypadIcon = GetEquivalentBitmapImagePath
                        (FULL_KEYPAD_ICON_RESOURCE_IDENTIFIER,
                         50, 80);
Button keypadBtn = new Button()
{
    HorizontalOptions = LayoutOptions.Fill,
    VerticalOptions = LayoutOptions.Fill
};
keypadBtn.ImageSource = fullKeypadIcon;

The following method is used to generate the PNG image:

private string GetEquivalentBitmapImagePath
        (string embeddedVectorIdentifier,
         float widthOfBitmapImage,
         float heightOfBitmapImage)
    {
        // For converting vector (.svg) images to raster images
        SKSvg svg;
        SKBitmap bitmap;
        SKCanvas canvas;
        SKImage image;
        SKData encodedData;
        Stream imageStream;

        string vectorImageFile;
        Stream embeddedResourceStream;
        FileStream vectorImageStream,
                   bitmapImageStream;
        string bitmapImagePath;

        if (widthOfBitmapImage < 1)
            throw new ArgumentException("Invalid value passed", "widthOfFinalImage");
        if (heightOfBitmapImage < 1)
            throw new ArgumentException("Invalid value passed", "heightOfFinalImage");

        try
        {
            vectorImageFile = Path.Combine(FileSystem.CacheDirectory, embeddedVectorIdentifier);
            embeddedResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedVectorIdentifier);
            vectorImageStream = new FileStream(vectorImageFile, FileMode.Create, FileAccess.Write);
            embeddedResourceStream.CopyTo(vectorImageStream);
            embeddedResourceStream.Flush();
            vectorImageStream.Flush();
            embeddedResourceStream.Close();
            embeddedResourceStream.Dispose();
            vectorImageStream.Close();
            vectorImageStream.Dispose();

            svg = new SKSvg(new SKSize(widthOfBitmapImage,
                                       heightOfBitmapImage));
            svg.Load(vectorImageFile);
            bitmap = new SKBitmap(Convert.ToInt32(svg.CanvasSize.Width),
                                  Convert.ToInt32(svg.CanvasSize.Height));
            canvas = new SKCanvas(bitmap);

            canvas.DrawPicture(svg.Picture);
            canvas.Flush();
            canvas.Save();
            image = SKImage.FromBitmap(bitmap);
            encodedData = image.Encode(SKEncodedImageFormat.Png, 100);
            bitmapImagePath = vectorImageFile.Replace(".svg", ".png");
            bitmapImageStream = File.Open(bitmapImagePath,
                                          FileMode.Create,
                                          FileAccess.Write,
                                          FileShare.None);
            encodedData.SaveTo(bitmapImageStream);
            bitmapImageStream.Flush(true);
            bitmapImageStream.Dispose();
            File.Delete(vectorImageFile);
            return bitmapImagePath;
        }
        catch (Exception ex)
        {
            throw;
        }
    }

Thanks in advance.

Problem view mp4 local video

$
0
0

Hi

I have a problem to show un *.mp4 on VideoView component. My code is this:

string path = @C:\Users\Desktop\sample.mp4;

Device.BeginInvokeOnMainThread(() => { CrossMediaManager.Current.Play("file://" + path ); });

Can you help me please


Issue with grouped list view

$
0
0
I am facing a wierd issue. I have a grouped list view it is working fine while loading the page, but when trying to load the same with same data on button click using a command, it's not showing up, anyone has any idea what is going on there

How to add admob ads in Xamarin Forms

$
0
0
Hi I need some help I've been trying to set this ads for month. Please help

How to get the file path of an image and send it to the server?

$
0
0

Hi everyone. Im currently learning Xamarin.Forms and I'm building my first application. Im using Xam.Media.Plugin to select or take a photo and save it to my server and It's working fine. But somehow, my requirements shifted so I looked around for another plugin and I discovered matheusneder/Xamarin.Forms.ImagePicker. This plugin covers all of my image processing requirements aside from it doesnt seem to save the image to the server. My REST API returns null for the image passed.
This is my code in selecting the image:
if (imageSource != null)
{
image.Source = imageSource;
new Alert("File path", imageSource.ToString(), "");
}
and this results to the file path being : /data/user/0/com.mysample.app/cache/cropped7799234235.jpg
In MediaPlugin, the file path result is : /storage/emulated/0/Android/data/com.mysample.app/files/Pictures/temp/IMG_20200915_104932_12.jpg

Im guessing that this somewhat related to file path? Any ideas on how to achieve the latter result?

Why is my app crashing on page load?

$
0
0

I have an app that until very recently was working ok, but now it is crashing when trying to push a new page. I am using XAML with CodeBehind and an MVVM approach.

I have a ListView which a user taps and entry on that should take them to the next page.

        async void Handle_ItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e)
        {
            if (e.Item == null)
                return;
            var race = e.Item as Race;

            await Navigation.PushAsync(new OnePage(race));
            //Deselect Item
            ((ListView)sender).SelectedItem = null;
        }

I can put a breakpoint on await Navigation.PushAsync(new OnePage(race));, step into the page constructor, step through every line in the page constructor which takes me into loading a view model.

public OnePage(Race race)
        {
            InitializeComponent();


            var viewModel = new OnePageViewModel(this, race);

            BindingContext = viewModel;
        }

Step through every line in the view model until it returns me to the code behind, which returns me back to the original await Navigation.PushAsync(new OnePage(race)); and the app crashes, totally freezes in the simulator (iOS and Android) and I have to stop the project in VS - before doing whatever it is meant to do next (which I am not sure about, as it should just load the page, there is no more of my code to execute).

I have emptied the XAML to ensure its not a problem with the XAML itself and narrowed it down to this section. Commenting it out makes the page load fine.

                <CollectionView.ItemsLayout>
                    <GridItemsLayout Orientation="Vertical" Span="4" />
                </CollectionView.ItemsLayout>

Using Xamarin 4.8 (latest NuGet) but have tried rolling back to all major versions to up to 4.4 in case its a collectionview issue. Can't put my finger on it.

The thing is, for the app to work the way I want it really needs to be the collectionview to give the required UI behaviour so don;t really have an alternative (That I can think of based upon the docs)

Any ideas?

Xamarin Form - Android upgrade to target v11 - Pipeline error

$
0
0

Hello all,
I am working on a Xamarin form project. For Android, I have upgrade the targetSDK to level 30 (Android 11). Everything is working fine on local. But When I run it on pipeline to get code coverage, ... it return the error as the image bellow

it worked fine before (targetSDK level 28).

Could you please give me any suggestion?

Device.StartTimer change speed from time to time xamarin

$
0
0

Device.StartTimer change speed from time to time xamarin. is anyone facing this problem. What is the solution of it.

Architecture for Azure + Xamarin?

$
0
0

I'm new to Xamarin and want to create a cross-platform app to replace a click-once WinForms app. I have a Sql Azure database that I want to keep using. But the components to use are beyond confusing. I need local (offline) storage of course. Is Microsoft still supporting Mobile? In what seems to be the right approach, I end up at: "app-service-mobile/app-service-mobile-value-prop" (sorry, as a first-time poster I'm not being allowed to publish the full link). At that location I see: "This content has been retired and may not be updated in the future. The product, service, or technology mentioned in this content is no longer supported." And that article was written on 6/25/2019.

So, what is "today's" approach to using an Azure back-end service (and database) + having offline (temporary) storage? I'm new to Sqlite too (but very well versed in Sql Server). Am I now facing a complete "roll my own" solution?


Handled global exception still my app is crashing

$
0
0

I am developing a application. i have done global exception handling in xamarin forms android by using below code

AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;

still my app is crashing if exception throws. Please help me to fix this issue. How can i handle exception globally without any crash.
Thanks in advance

Issues trying to debug on 4.0.3 device

$
0
0

Hello there!

I have a project that was working OK. I was testing on a device with Android 4.1.1, so I have set the Android configuration with that version as the minimum. Compilation SDK and target are set as 9.0. So far, so good.

But now, I need to try it on a 4.0.3 Android device and I'm having issues.
Of course, I changed minimum version, I installed Android SDK PLatform 15 from SDK Manager in Visual Studio 17, cleaned project, restart... But when I try to debug, this exception appears:

Java.Lang.NoSuchMethodError: no method with name='getLineSpacingMultiplier' signature='()F' in class Landroid/widget/TextView;

I was googling for half and an hour looking for some clue. Of course, it looks like some methods are no working because it's a very old version of Android, but I have no choice but to make it works in this device, with no chance of updating it.
The most similar answer I got was this thread:
https://forums.xamarin.com/discussion/161342/java-lang-nosuchmethoderror-no-method-with-name-getlinespacingmultiplier-signature-f-in-class
But setting Minimum version to 4.1.1 doesn't let me debug on the device (and I need to check some HW behaviour).

What can I do?
Is there a way to override all the non-existing methods like the above mentioned, if there is no way I can set the environment to test it?

Thank you!

Application only working properly on emulator

$
0
0

Hello, I'm new to Xamarin development and I'm facing a problem that I can't solve.
I've created a project with only the default Xamarin welcome screen in it.
The problem is that when I run it on my device (Xiaomi Redmi Note 7 - Android 10) it isn't showing some of the content, but with the Android 10 emulator it's working fine.
I tried to test with different device with Android 10, but the problem remained.
The target framework is set to Android 10, the minimum version to 6.
I've also tried it with a 6 version device and it's working on it.
Is there some reference's or packages that I'm missing for Android 10 development?
I tried to search for some solution but so far I couldn't find anything yet.

I also made some screenshots to demonstrate the problem.
Emulator:

image
image

Device:

image
image

Entry control is firing Focused event on every cursor blink

$
0
0

Hi,

I found out that the Entry control's event "Focused" is being fired up every time the cursor blinks... So let's say you have simple code:
MyEntry.Focused += (object sender, FocusEventArgs e) =>{ someCode };
you start the app, you click in the entry, the cursor starts to blink -> every blink will fire up this code.

Do you guys think this is how the Focused should be used? I have reported this as a bug, any thoughts?

:)

Please tell i think the Device.StartTimer is not working with the Interval we have define

$
0
0

I have define the interval of 2 mins but its not give the interval of 2 mins. Their must be some issue with the Xamarin. What other option we have for the backgroundservice to call

Device.StartTimer(TimeSpan.FromMinutes(2), () =>

            {




                    MessagingCenter.Send<string>("OK", "counterValue");



                return true;

            }
            );
Viewing all 91519 articles
Browse latest View live


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