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

Passing Arguments in XAML

$
0
0

I'm trying to pass arguments in XAML to my own class following:
passing arguments

like:

<MyClass>
    <x:Arguments>
            <x:Boolean>true</x:Boolean>
            <x:Double>90</x:Double>
    </x:Arguments>
</MyClass>

But when I add this I get an error saying:

The given key was not present in the dictionary.

If I hard code it inside my constructor instead, it all works fine, but I want to be able to change it.


empty toolbox in both xamarin studio and visual satudio 2013 unsing xamarin forms

$
0
0

I have an empty toolbox in both xamarin studio and visual satudio 2013 unsing xamarin forms.

I am editing a xaml file and there are no controls in the toolbox.

Also in xamarin studio I do not get any kind of 'designer' view... only XML view...

in visual studio I get an error trying to view the 'design' view. It is not rendering the view... so it makes it impossible to see what is laid out etc...

Any reason why?

I find it unusable without a toolbox... how does others get around this?

HttpClient in xamarin.forms PCL assembly cannot be referenced

$
0
0

I am trying to do a facebook sign in page for my android platform, however I keep getting this error. I tried installing the Nuget package httpClient also but to no avail. I also tried referencing using Windows.Web.Http;

The error:
The Type 'IAsyncOperationWithProgress<,>'is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.FoundationContract, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.

My Code:
public async Task GetFacebookProfileAsync(string accessToken)
{
var requestUrl = "https://graph.facebook.com/v2.10/me/" + "?fields=name,picture,cover,age_range,devices,email,gender,is_verified" + "&access_token=" + accessToken;
var httpClient = new HttpClient();
var userJson = await httpClient.GetStringAsync(requestUrl);
}

Android App crashes after receiving push notification

$
0
0

Specifically, after I swipe the app off of recents, and send a notification using GCM, I receive "Unfortunately, MyApp has stopped working.". In fact, I receive this message twice for some reason, the second time comes about 10 seconds after clicking 'Ok' on the first one.

Notifications are working correctly when the app is running (foreground and background), its only after swiping it off screen do I get this error. I am able to receive notifications after I close the app if I use Baidu Push, so I know it should be possible with GCM too.

Here is the code that is causing the crash:

    [Service(Name = "my.pkg.name.MyGcmListenerService", Exported = true),
        IntentFilter(new[] { "com.google.android.c2dm.intent.RECEIVE" })]
    public class MyGcmListenerService : GcmListenerService
    {
        const string TAG = "MyGcmListenerService";

        public override void OnMessageReceived(string from, Bundle data)
        {
            // If I uncomment this try catch block, the crash doesn't happen.
            // But I still receive no notification, as there is still an exception occurring.
            // Also, the LogManager class writes the error to a .txt file, however if the
            // app is swiped off screen, it doesn't write to that file, so I don't know
            // exactly what the error is.

            //try
            //{
                CreateNotification("msg title", "new message!!!");
            //}
            //catch (Exception ex)
            //{
            //    LogManager.Instance.Log("MyGcmListenerService - OnMessageReceived ERROR: " + ex.ToString());
            //}
        }

        private void CreateNotification(string title, string message)
        {
            var intent = new Intent(Xamarin.Forms.Forms.Context, typeof(MainActivity));
            intent.AddFlags(ActivityFlags.ClearTop);
            var pendingIntent = PendingIntent.GetActivity(Xamarin.Forms.Forms.Context,
                0, intent, PendingIntentFlags.OneShot);

            var notificationBuilder = new NotificationCompat.Builder(Xamarin.Forms.Forms.Context)
                .SetSmallIcon(Resource.Drawable.icon)
                .SetContentTitle(title)
                .SetContentText(message)
                .SetAutoCancel(true)
                .SetContentIntent(pendingIntent);

            var notificationManager =
                (NotificationManager)Xamarin.Forms.Forms.Context.GetSystemService(
                    Android.Content.Context.NotificationService);

            notificationManager.Notify(0, notificationBuilder.Build());
        }

    }

App crash immediatly at startup with 'Fatal signal 6 (SIGABRT)' error message

$
0
0

Hi everyone,

I'm a new Xamarin Forms developper (about 2 month old) and I'm facing a big problem when I execute my Xamarin Forms Android application.
I search on the Xamarin forum and on Google for a solution but nothing helped me.
When I execute the application in debug mode (with Visual Studio or Xamarin Studio : same behavior), compilation is ok, application is deployed on my phone and is launching on it.
A black screen appear (as if the Xamarin loading page was going to appear) but suddenly disapear ... but without any handle on Visual Studio and no explicit error message.

This is the complete debug log from Visual Studio :

Android application is debugging.
Could not connect to the debugger.
11-19 16:44:37.434 E/Zygote  (27652): MountEmulatedStorage()
11-19 16:44:37.434 E/Zygote  (27652): v2
11-19 16:44:37.434 I/libpersona(27652): KNOX_SDCARD checking this for 10319
11-19 16:44:37.434 I/libpersona(27652): KNOX_SDCARD not a persona
11-19 16:44:37.474 I/SELinux (27652): Function: selinux_compare_spd_ram, SPD-policy is existed. and_ver=SEPF_GT-I9506_5.0.1 ver=27
11-19 16:44:37.474 I/SELinux (27652): Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_GT-I9506_5.0.1-1_0039
11-19 16:44:37.474 E/SELinux (27652): [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
11-19 16:44:37.474 I/art     (27652): Late-enabling -Xcheck:jni
11-19 16:44:37.544 D/ResourcesManager(27652): creating new AssetManager and set to /data/app/DicTMobile.DicTMobile-1/base.apk
11-19 16:44:37.574 W/monodroid(27652): Using override path: /data/data/DicTMobile.DicTMobile/files/.__override__
11-19 16:44:37.574 W/monodroid(27652): Using override path: /storage/emulated/0/Android/data/DicTMobile.DicTMobile/files/.__override__
11-19 16:44:37.574 W/monodroid(27652): Trying to load sgen from: /data/data/DicTMobile.DicTMobile/files/.__override__/libmonosgen-2.0.so
11-19 16:44:37.584 W/monodroid(27652): Trying to load sgen from: /storage/emulated/0/Android/data/DicTMobile.DicTMobile/files/.__override__/libmonosgen-2.0.so
11-19 16:44:37.584 W/monodroid(27652): Trying to load sgen from: /data/app/DicTMobile.DicTMobile-1/lib/arm/libmonosgen-2.0.so
11-19 16:44:37.584 W/monodroid(27652): Trying to load sgen from: /data/data/DicTMobile.DicTMobile/files/.__override__/links/libmonosgen-2.0.so
11-19 16:44:37.584 W/monodroid-debug(27652): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8989,server=y,embedding=1
11-19 16:44:37.634 W/monodroid-debug(27652): Accepted stdout connection: 26
11-19 16:44:38.404 F/        (27652): * Assertion at /Users/builder/data/lanes/2098/3efa14c4/source/mono/mono/metadata/class.c:5078, condition `class' not met
11-19 16:44:38.404 F/libc    (27652): Fatal signal 6 (SIGABRT), code -6 in tid 27652 (bile.DicTMobile)

The problem has muted before this :

  • First time a exception was throwed at startup about a missing public constructor on the fist ViewModel loaded (while in fact there was here !)
    I search during few hours without success.

  • Next day exception disappear as if by magic ! Very strange ! Now application is running well and I can tap on my login button and arrive on my main page and ... finaly crash few seconds later ... I'm amazed !
    At this point there is still no handle on any exception on Visual Studio.
    Console out give this at end (not the same code but similar) :

    E/mono-rt(15933): =================================================================
    E/mono-rt(15933): Got a SIGSEGV while executing native code. This usually indicates
    E/mono-rt(15933): a fatal error in the mono runtime or one of the native libraries
    E/mono-rt(15933): used by your application.
    E/mono-rt(15933): =================================================================
    A/libc(15933): Fatal signal 11 (SIGSEGV) at 0x0000001d (code=1)

  • Third day ... i'm exhausted. I don't know neither what nor or look.
    Stable Xamarin Forms 4.0 is out, i decide to update my project, who know, maybe it's my solution ! Hope makes live !
    In fact Xamarin has worked on Forms optimization that made it up to 2 time faster.
    Now my problem appears immediatly ....

I'm becoming crazy, are threre somebody to help me ? Please help !

(I hope my readable English because I'm French)

Can not build anymore error CS0006 metadata file could not be found

$
0
0

Hi,
one build run of my Xamarin.Forms project was hangging and i had to close VS2017 with task manager.
From this time on I can not build my project anymore...

Iam getting the Error: CS0006 Metadata file 'C:\Projects\MyApp\MyApp\bin\Debug\MyApp.dll' could not be found
MyApp.UWP CSC 1 Active

And the same for the iOS project...

What Ive tried:

  • Windows and VS reboot
  • Project unload in VS
  • Clean every project and rebuild
  • Uninstall and back Install Xamarin.Forms NuGET
  • Delete all "bin" and "obj" folders and "packages.config" files

Please help me with this, Ive no Idea how I can fix this :(

Xamarin.Forms Label different behaviour

$
0
0

On IOS label which have no text does not reserve any space in the layout, but on android it does.

I created two labels with different style. If one property of bound object is set - the first label is visible, if alternate property is set, then second label is being used.

XAML:

 <StackLayout Orientation="Vertical" WidthRequest="80" >
        <StackLayout Spacing="0" Orientation="Vertical" VerticalOptions="EndAndExpand" >
            <Label Text="{Binding ThumbnailTitle}" FontSize="26" HorizontalTextAlignment="Center" LineBreakMode="NoWrap"/>
            <Label Text="{Binding ThumbnailTitleSmall}" FontSize="18" HorizontalTextAlignment="Center"/>
        </StackLayout>
        <Label Text="{Binding ThumbnailSubtitle}" VerticalOptions="StartAndExpand" LineBreakMode="NoWrap" FontSize="15" HorizontalTextAlignment="Center" />
    </StackLayout>

Thats works fine on iOS, but on Android, as you can see on screenshot, it leaves empty space at the place of empty label.

Visual Studio Community 2017 for Mac
Version 7.0.1 (build 24)

Apple Developer Tools
Xcode 8.3.3 (12175.1)

Xamarin.iOS
Version: 10.10.0.36 (Visual Studio Community)

Xamarin.Android
Version: 7.3.1.2 (Visual Studio Community)
Android SDK: /Users/ilya/Documents/android-sdk-macosx
Supported Android versions:
7.1 (API level 25)

Xamarin forms Map => Get driving time between 2 position ?

$
0
0

Hello the Api google map allow to get driving time bewteen 2 adress, and i want to know if it's possible with xamarin forms map or any plugin ?

i need to calcul drivingtime bewteen 1 guy for 1000 adress different in a row so with the api google i would launch 1000 internet request so bad perfomance

what do you think about my problem ?

thx


Converted PCL to Net Std lib. Now can't create new pages?

$
0
0

I recenty went through the process of converting all PCL's in my solution to .net standard libraries (not sure if its related nor not, just mentioning it in case).
Now, when I try and add a page, It adds the Xaml and the xaml.cs files into the project without any link or connection, so they wont compile:

Googling suggests I can go in and edit the .csproj to add a dependency between the two, but this is a horrible solution long term.
Any way to fix this "properly"?

I've tried dragging and dropping existing files in from windows explorer into VS2017, adding new through the add new dialog, adding existing through add existing and it all exhibits the same behaviour.

Thanks

Attempt by method 'XXX.App.InitializeComponent()' to access method 'XXX.yyyConverter..ctor()' failed

$
0
0

The InitializeComponent() call form the App() constructor throws following exception

...
Attempt by method 'XXX.App.InitializeComponent()' to access method 'XXX.yyyConverter..ctor()' failed
...

The view is located in a .NetStandard project accessed by the platform-specifc projects (Droid, UWP, iOS), the yyyConverter is a custom IValueConverter located in the same assembly. The view contains a ListView with several DataTemplates and Binding.

Getting Screen Elements to Respond Immediately

$
0
0

I'm working in Xamarin.Forms. I have a button that does some work before returning from that page. This causing a visually jarring lag. I'd like to prevent users from getting impatient by creating an ActivityIndicator so that they are aware the app has not frozen and is responding. I can place the element just fine. The method called from the button has a line changing the bounded boolean value. However despite being in two way mode and implementing OnPropertyChanged, I cannot get the loading animation to appear before the page freezes while working.

Firebase - Info on logged user

$
0
0

I need help. I'm doing login with firebase in my app, but i don't know how to get info on logged user and how i can know if a user is already logging in, also in different page from login.
I'm using this API https://github.com/rlamasb/Firebase.Xamarin , but i don't find info on this.
How can I do? Thanks

How to find the image that is not found on iOS

$
0
0

Hi all,

I get this error:
System.Exception: Could not initialize an instance of the type 'MonoTouch.UIKit.UIImage': the native 'initWithContentsOfFile:' method returned nil.
It is possible to ignore this condition by setting MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.
at MonoTouch.Foundation.NSObject.InitializeHandle (IntPtr handle, System.String initSelector) [0x000b0] in /Developer/MonoTouch/Source/maccore/src/Foundation/NSObject2.cs:399
at MonoTouch.UIKit.UIImage..ctor (System.String filename) [0x00026] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/UIImage.g.cs:239
at Xamarin.Forms.Platform.iOS.FileImageSourceHandler.LoadImageAsync (Xamarin.Forms.ImageSource imagesource, CancellationToken cancelationToken, Single scale) [0x00000] in :0
at Xamarin.Forms.Platform.iOS.ImageRenderer+d__0.MoveNext () [0x00000] in :0

But only on a real device, not in the simulator. So best bet is that somewhere the filename case is wrong, or it might call Bundleresource instead of FileResource. I checked all filenames, and they seem to be OK. I checked multiple levels of the exception data to find any indication of the filename that is missing or is giving a problem. But as this is loaded async, settings breakpoints and debug messages did not help.

I checked if all files are set to BundleResource, and they are referred to by using ImageSource.FromFile (image-name)

Who is giving me a hint which image or resource could give me this trouble?

Preloading Images with FFImageLoading

$
0
0

Background: I have a custom ContentPage I'm reusing and occasionally loading images into. A CachedImage gets loaded into a StackLayout that is centered within an AbsoluteLayout. Since I'm setting the CachedImage.Source in the code, the image height wasn't adjusting the size of the StackLayout and it wouldn't center vertically. After doing some extensive testing I've got FFImageLoading preloading images, adding the CachedImage and forcing the layout so it shows up centered!

I'm so happy it works I wanted to share my code!

XAML (partial)

<AbsoluteLayout x:Name="absoluteLayout" HorizontalOptions="Fill" VerticalOptions="Fill">
    <StackLayout x:Name="mainLayout" Margin="15" Spacing="20" VerticalOptions="Center"
        AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1">
        <!-- Elements go here -->
    </StackLayout>
</AbsoluteLayout>

Code:

public AlertPage()
{
    InitializeComponent();

    var imageFile = "dynamic_image"; // I get this dynamically
    if (imageFile != null)
    {
        // Preload image so it's width/height can adjust layout
        TaskParameter imageTask;
        // iOS requires the extension, Android loads from CompiledResource
        if (Device.RuntimePlatform == Device.iOS)
        {
            imageFile = string.Format("{0}.png", imageFile);
            imageTask = ImageService.Instance.LoadFile(imageFile);
        }
        else
        {
            imageTask = ImageService.Instance.LoadCompiledResource(imageFile);
        }

        imageTask.Error((Exception obj) =>
        {
            Debug.WriteLine("LoadFile Error: {0}", obj);
        });
        imageTask.Success((ImageInformation info, LoadingResult result) =>
        {
            Debug.WriteLine("LoadFile Success: {0} : {1}", info, result);

            Device.BeginInvokeOnMainThread(() =>
            {
                var image = new CachedImage
                {
                    Source = imageFile
                };
                mainLayout.Children.Insert(0, image);
                absoluteLayout.ForceLayout();
            });
        });
        imageTask.Preload();
    }

    ... // Rest of page creation
}

Missing System.Runtime 4.1.0 in my UWP project

$
0
0

Hi everyone

I'm having a hard time creating my first UWP app with Xamarin Forms.

When I first created it, just for testing purpose, I ran the blank solution and everything worked fine, both in Local Machine and in the Emulator.

I added the references for my solution that's already running in Android:

"Autofac": "4.0.0",
"Expressmapper": "1.8.3",
"Microsoft.Azure.Mobile.Client": "3.0.3",
"Microsoft.Azure.Mobile.Client.SQLiteStore": "2.1.1",
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
"Xamarin.Forms": "2.3.2.127",
"Xamarin.Forms.Maps": "2.3.2.127"

And at this moment if I try to run the solution I get this error after being deployed when it starts to run:

_An exception of type 'System.IO.FileLoadException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)_

I have no reference of System.Runtime in my project, and if I check the bin folder for the project, indeed, the System.Runtime.dll version is not 4.1.0 but 4.6.23123.0

Anyone got a clue about this? It's 2 days I've wasted trying to fix this error...

Cheers!


Image alignment in UWP is wrong (left instead of center). Workaround?

$
0
0

This problem has been reported in the bug

https://bugzilla.xamarin.com/show_bug.cgi?id=50638

Does anyone have an easy workaround? (easy meaning not having to rewrite the entire UI structure around the image.)

And how do we get the Xamarin team to fix this bug? It is marked with importance normal major and should be quite easy fi fix. Still it have been laying there since December 2016 with seemingly no progress at all.

Thanjs
Jimmi

Does not not deployed to emulator or device on Android Xamarin.Forms

$
0
0

I have a problem when running an application in Xamarin Forms, when I run iOS it works without problem, but when trying to run on Android this is compiling and never ends (Xamarin Studio and Visual Studio For Mac)

Any suggestions?

Xamarin Live Player with Visual Studio 2017 Preview not working

$
0
0

I cannot get to see the Xamarin Live Player with Visual Studio 2017 Preview even after doing everything that is stated in various articles online.
Just wondering if someone could help with what I should be doing to get it working.


I have followed the article below and it does not seem to get me in the right direction. Appreciate your time and help here.

regards,
Sachin

Android App crashes for Xamarin using Native Views sample

$
0
0

Hi, I'm trying to follow this guide:
https://developer.xamarin.com/guides/xamarin-forms/platform-features/native-views/#consuming
Specifically, I'm using the first "Hello World" snippet for default "Cross Platform App (Xamarin)" created by VS2017 by just replacing MainPage.xaml content in "Portable" lib.
First issue I'm having is that Resharper goes crazy about clr-namespace:Android.Widget and clr-namespace:Xamarin.Forms but this is another problem as everything compiles fine. However, my App crashes immediately.
I'm using 7.1 SDK and targeting the same. For portable lib, I've referenced Mono.Android (7.1) and Xamarin.Forms.Platform.Android manually but I'm not sure this is necessary as xaml is being parsed at runtime anyway, right (I'm new to Xamarin)?
Any ideas what's wrong?

Circle button in Xamarin.Forms. Super easy way

$
0
0

Guys, there is super easy way to create Circle/Round buttons in XF.
What you need to do is to use BorderRadius, WidthRequest and HeightRequest (you must use all these properties)
Make in mind simple formula:
WidthRequest = BorderRadius * 2
HeightRequest = BorderRadius * 2

or another way:
BorderRadius = WidthRequest / 2
BorderRadius = HeightRequest / 2

So finally, if your WidthRequest and HeightRequest both are equals 40, then your BorderRadius will be 20.
See the attached screens for this simple and nice hack :)

simple text:

font awesome:

Viewing all 89864 articles
Browse latest View live


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