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

PanGestureRecognizer not working in Android (Xamarin Forms)

$
0
0

I recently created a custom control that contains two child controls within a Grid. I added a PanGestureRecognizer to the custom control to move the child controls through the Y axis when the PanUpdated event fires. This works fine in iOS, but Android does not fire the PanUpdated event.

To investigate I looked at the example of how to do pan gestures here: https://developer.xamarin.com/guides/xamarin-forms/user-interface/gestures/pan/

This example works on Android, but as soon as you change the Image inside the PanContainer to something else, say a Grid containing some other controls, then PanUpdated stops firing. As I mentioned this all works well on iOS.

I'm currently using XF 2.3.3.180

Can anyone offer any help or guidance on how to get the pan gesture working in Android?


Global Variables

$
0
0

What is the concensus on using global variables in xamarin forms? Are they encouraged with regards to using viewmodels? How do they fit in MVVM?

MasterDetailPage

$
0
0

Is there a way to use the MasterDetailPage without the default titleBar and Icon?

Script APK Creation to automate archive process

$
0
0

Hello,
I would ask if somebody knows a way to automate the process of apk creation and sign, because every time that I have to produce an apk to distribute I have to rebuild my solution, then create the archive, then distribute it choosing the certificate, and I would like if all this process could be done with a single action instead of this continous interaction.

Thank you

Navigation.PushAsync from TabbedPage then hit back button causes crash

$
0
0

I see there is a bug report which has been fixed but interestingly I still have this problem with the latest stable XF (2.3.3.175).
See: https://bugzilla.xamarin.com/show_bug.cgi?id=35811

On a TabbedPage when I do:

    await Navigation.PushAsync(new ContentPage());

It displays a blank ContentPage (as expected) but when I hit the back button it goes back to the TabbedPage but everything is frozen. Can't interact with any of the children.

Interestingly, this only happens on Android 5.x devices and 5.x emulators. It works OK on Android 4.x and 6.x devices and emulators.

Any help would be appreciated.

Referencing Apple SF Medium Weight Font in App.xaml Resource Dictionary

$
0
0

I have setup different brand styles in the App.xaml resource dictionary for Android and iOS. I have been trying set the San Francisco Medium and Light fonts using the OnPlatform tag below:

<OnPlatform
    x:Key="MediumFontFamily"
    x:TypeArguments="x:String"
    iOS="SanFranciscoText-Medium"
    Android="sans-serif-medium"
    WinPhone="" />

Android works as expected but iOS always renders SF Text Regular. I realize that when the app renders on iOS, SanFranciscoText-Medium (and/or Light) is not found and the system defaults to the system font. That is fine for styles utilizing regular font weight but not for my headline and title styles. I have read plenty of post online that instruct us to avoid using specific font names in iOS and others that recommend including the fonts as a resource in the iOS project.

Most of our layout and styles are handled in XAML. How can I set the medium weight font above so that my headline styles render correctly on iOS? Ideally, I would like to be able to use the UIText.systemFont so that the system handles switching between display and text fonts but I have not figured out how to use that in a Xamarin Forms application. If possible, we would like to avoid refactoring all of our styles so we would prefer to stick with the XAML methods.

Any help would be appreciated.

Full Screen Image Viewer (with Pinch to Zoom, Pan to Move, Tap to show captions) for Xamarin forms.

$
0
0

I'm working on a full screen image page that supports pinch to zoom, pan to move and tap to show captions. I'm basing this on how image viewer works in apps such as Facebook and Yelp. My code is built off Xamarin examples on gesture recognizers, which can be found at https://developer.xamarin.com/guides/xamarin-forms/user-interface/gestures/

My problem is that when the image is zoomed in and I rotate the device, and then zoomed out. The image is off the center. I would really appreciate it very much if someone can help me finish this, so it supports varying device orientations.

using System;
using System.ComponentModel;
using Xamarin.Forms;

namespace TurfDoctor
{
    public class FullScreenImagePage : ContentPage
    {
        double currentScale = 1;
        double startScale = 1;
        double xOffset = 0;
        double yOffset = 0;

        double originalWidth;
        double originalHeight;

        double ScreenWidth;
        double ScreenHeight;

        PanGestureRecognizer panGesture;

        bool showEverything = false;
        StackLayout imageDescription;
        Button backButton;
        BoxView topBox;
        Image image;
        ContentView imageContainer;
        Label indexLabel;
        //Label xLabel, yLabel, transXLabel, transYLabel, widthLabel, heightLabel, scaleLabel, screenWidthLabel, screenHeightLabel;
        AbsoluteLayout absoluteLayout;

        protected override void OnAppearing ()
        {
            ShowEverything = true;
            base.OnAppearing ();
        }

        protected override bool OnBackButtonPressed ()
        {
            App.NavPage.BarTextColor = Color.Black; // turn the status bar back to black
            return base.OnBackButtonPressed ();
        }

        public bool ShowEverything
        {
            set{
                    showEverything = value;
                    backButton.IsVisible = showEverything;
                    imageDescription.IsVisible = showEverything;
                    topBox.IsVisible = showEverything;
                    indexLabel.IsVisible = showEverything;

                    if (!showEverything) {
                        // hide the status bar by turning it black
                        App.NavPage.BarTextColor = Color.Black;
                        imageContainer.GestureRecognizers.Add (panGesture);
                    } else {
                        // show the status bar by turning it white
                        App.NavPage.BarTextColor = Color.White;
                        imageContainer.GestureRecognizers.Remove (panGesture);
                    }
            }
            get{
                return showEverything;
            }
        }

        public FullScreenImagePage (String ImageName, string DescriptionText, int index, int count)
        {
            NavigationPage.SetHasNavigationBar (this, false);

            image = new Image {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Aspect = Aspect.AspectFill,
                Source = ImageName
            };

            imageContainer = new ContentView {
                Content = image
            };

            var tapGesture = new TapGestureRecognizer ();
            tapGesture.Tapped += OnTapped;
            imageContainer.GestureRecognizers.Add (tapGesture);

            var pinchGesture = new PinchGestureRecognizer ();
            pinchGesture.PinchUpdated += OnPinchUpdated;
            imageContainer.GestureRecognizers.Add (pinchGesture);

            panGesture = new PanGestureRecognizer ();
            panGesture.PanUpdated += OnPanUpdated;
            imageContainer.GestureRecognizers.Add (panGesture);

            absoluteLayout = new AbsoluteLayout {
                BackgroundColor = MyAppStyle.blackColor,
            };

            var label = new Label {
                Text = DescriptionText,
                TextColor = MyAppStyle.whiteColor,
                FontAttributes = FontAttributes.Bold,
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label))
            };
            var separator = new BoxView() { HeightRequest = 1, BackgroundColor = MyAppStyle.whiteColor};

            imageDescription = new StackLayout {
                Padding = new Thickness(20),
                HorizontalOptions = LayoutOptions.Fill,
                Orientation = StackOrientation.Vertical,
                Children = { label, separator}
            };

            backButton = new Button { Text = "Back", WidthRequest = 80, HeightRequest = 40, TextColor = MyAppStyle.whiteColor, FontAttributes = FontAttributes.Bold };
            backButton.Clicked += (object sender, EventArgs e) => { OnBackButtonPressed(); Navigation.PopAsync(); };

            indexLabel = new Label {
                Text = (index + 1).ToString () + " of " + count.ToString (),
                TextColor = MyAppStyle.whiteColor,
                FontAttributes = FontAttributes.Bold,
                HorizontalTextAlignment = TextAlignment.Center
            };

            AbsoluteLayout.SetLayoutFlags (imageContainer, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds (imageContainer, new Rectangle (0f, 0f, 1f, 1f));
            absoluteLayout.Children.Add (imageContainer);

            AbsoluteLayout.SetLayoutFlags (imageDescription, AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);
            AbsoluteLayout.SetLayoutBounds (imageDescription, new Rectangle(0f, 1f, 1f, AbsoluteLayout.AutoSize));
            absoluteLayout.Children.Add(imageDescription);

            topBox = new BoxView { Color = MyAppStyle.blackColor, Opacity = 0.5 };
            AbsoluteLayout.SetLayoutFlags (topBox, AbsoluteLayoutFlags.WidthProportional);
            AbsoluteLayout.SetLayoutBounds (topBox, new Rectangle(0f, 0f, 1f, 50f));
            absoluteLayout.Children.Add (topBox);

            AbsoluteLayout.SetLayoutFlags (backButton, AbsoluteLayoutFlags.None);
            AbsoluteLayout.SetLayoutBounds (backButton, new Rectangle(0f, 10f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            absoluteLayout.Children.Add (backButton);

            AbsoluteLayout.SetLayoutFlags (indexLabel, AbsoluteLayoutFlags.XProportional);
            AbsoluteLayout.SetLayoutBounds (indexLabel, new Rectangle(.5f, 20f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            absoluteLayout.Children.Add (indexLabel);

            Content = absoluteLayout;
        }

        protected override void OnSizeAllocated(double width, double height)
        {
            base.OnSizeAllocated(width, height); //must be called

            if (ScreenWidth != width || ScreenHeight != height) {

                absoluteLayout.ForceLayout();

                originalWidth = imageContainer.Content.Width /  imageContainer.Content.Scale;
                originalHeight = imageContainer.Content.Height / imageContainer.Content.Scale;

                ScreenWidth = width;
                ScreenHeight = height;

                xOffset = imageContainer.Content.TranslationX;
                yOffset = imageContainer.Content.TranslationY;

                currentScale = imageContainer.Content.Scale;
            }
        }

        void OnTapped(object sender, EventArgs e)
        {
            ShowEverything = !ShowEverything;
        }

        void OnPanUpdated (object sender, PanUpdatedEventArgs e)
        {
            var s = (ContentView)sender;

            // do not allow pan if the image is in its intial size
            if (currentScale == 1)
                return;

            switch (e.StatusType) {
            case GestureStatus.Running:

                double xTrans = xOffset + e.TotalX, yTrans = yOffset + e.TotalY;
                // do not allow verical scorlling unless the image size is bigger than the screen
                s.Content.TranslateTo (xTrans, yTrans, 0, Easing.Linear);

                break;

            case GestureStatus.Completed:
                // Store the translation applied during the pan
                xOffset = s.Content.TranslationX;
                yOffset = s.Content.TranslationY;

                // center the image if the width of the image is smaller than the screen width
                if (originalWidth * currentScale < ScreenWidth && ScreenWidth > ScreenHeight)
                    xOffset = (ScreenWidth - originalWidth*currentScale)/2 - s.Content.X;
                else
                    xOffset = Math.Max (Math.Min (0, xOffset), -Math.Abs (originalWidth * currentScale - ScreenWidth));

                // center the image if the height of the image is smaller than the screen height
                if (originalHeight * currentScale < ScreenHeight && ScreenHeight > ScreenWidth)
                    yOffset = (ScreenHeight - originalHeight*currentScale)/2 - s.Content.Y;
                else
                    yOffset = Math.Max (Math.Min ((originalHeight - ScreenHeight)/2, yOffset), -Math.Abs(originalHeight*currentScale - ScreenHeight - (originalHeight - ScreenHeight)/2));

                // bounce the image back to inside the bounds
                s.Content.TranslateTo (xOffset, yOffset, 500, Easing.BounceOut);
                break;
            }
        }

        void OnPinchUpdated (object sender, PinchGestureUpdatedEventArgs e)
        {
            var s = (ContentView)sender;

            if (e.Status == GestureStatus.Started) {
                // Store the current scale factor applied to the wrapped user interface element,
                // and zero the components for the center point of the translate transform.
                startScale = s.Content.Scale;
                s.Content.AnchorX = 0;
                s.Content.AnchorY = 0;
            }
            if (e.Status == GestureStatus.Running) {

                // Calculate the scale factor to be applied.
                currentScale += (e.Scale - 1) * startScale;
                currentScale = Math.Max (1, currentScale);
                currentScale = Math.Min (currentScale, 5);

                //scaleLabel.Text = "Scale: " + currentScale.ToString ();

                if (currentScale == 1)
                    ShowEverything = true;
                else
                    ShowEverything = false;

                // The ScaleOrigin is in relative coordinates to the wrapped user interface element,
                // so get the X pixel coordinate.
                double renderedX = s.Content.X + xOffset;
                double deltaX = renderedX / ScreenWidth;
                double deltaWidth = ScreenWidth / (s.Content.Width * startScale);
                double originX = (e.ScaleOrigin.X - deltaX) * deltaWidth;

                // The ScaleOrigin is in relative coordinates to the wrapped user interface element,
                // so get the Y pixel coordinate.
                double renderedY = s.Content.Y + yOffset;
                double deltaY = renderedY / ScreenHeight;
                double deltaHeight = ScreenHeight / (s.Content.Height * startScale);
                double originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight;

                // Calculate the transformed element pixel coordinates.
                double targetX = xOffset - (originX * s.Content.Width) * (currentScale - startScale);
                double targetY = yOffset - (originY * s.Content.Height) * (currentScale - startScale);

                // Apply translation based on the change in origin.
                var transX = targetX.Clamp (-s.Content.Width * (currentScale - 1), 0);
                var transY = targetY.Clamp (-s.Content.Height * (currentScale - 1), 0);
                s.Content.TranslateTo (transX, transY, 0, Easing.Linear);

                // Apply scale factor.
                s.Content.Scale = currentScale;
            }
            if (e.Status == GestureStatus.Completed) {
                // Store the translation applied during the pan
                xOffset = s.Content.TranslationX;
                yOffset = s.Content.TranslationY;

                // center the image if the width of the image is smaller than the screen width
                if (originalWidth * currentScale < ScreenWidth && ScreenWidth > ScreenHeight)
                    xOffset = (ScreenWidth - originalWidth*currentScale)/2 - s.Content.X;
                else
                    xOffset = Math.Max (Math.Min (0, xOffset), -Math.Abs (originalWidth * currentScale - ScreenWidth));

                // center the image if the height of the image is smaller than the screen height
                if (originalHeight * currentScale < ScreenHeight && ScreenHeight > ScreenWidth)
                    yOffset = (ScreenHeight - originalHeight*currentScale)/2 - s.Content.Y;
                else
                    yOffset = Math.Max (Math.Min ((originalHeight - ScreenHeight)/2, yOffset), -Math.Abs(originalHeight*currentScale - ScreenHeight - (originalHeight - ScreenHeight)/2));

                // bounce the image back to inside the bounds
                s.Content.TranslateTo (xOffset, yOffset, 500, Easing.BounceOut);
            }
        }
    }
}

ObjectDisposedException in VisualElementRenderer (Android)

$
0
0

Hi Xamarin Team.

We have been battling an intermittent issue in the last several weeks with an System.ObjectDisposedException being thrown in the VisualElementRenderer for Android. Looking on the forums and BugZilla, there have been many similar reports with slightly different repros. However, it seems isolated to a fairly recent release of Xamarin.Android and/or Xamarin.Forms.

Here is an abbreviated stack trace showing the exception thrown.

Unhandled Exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Android.Views.GestureDetector
at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Android.Views.View.IOnTouchListener.OnTouch...VisualElementRenderer.cs:104

We have a custom collection view control which we have built which is rendered using a UICollectionView on iOS, RecyclerView on Android and GridView on UWP. This view has been considered stable code for some time now and has been working flawlessly for many months. However, we noticed this exception when we upgraded to XF 2.3.3 and subsequently updated to the latest release of Xamarin.Android in the stable channel.

We note a similar issue has already been reported in several BugZilla reports.
https://bugzilla.xamarin.com/show_bug.cgi?id=42678
https://bugzilla.xamarin.com/show_bug.cgi?id=45330
https://bugzilla.xamarin.com/show_bug.cgi?id=47158

On one of the bug reports, it was suggested ObjectDisposedExceptions could be related to the new Tarjan GC which is the default in Xamarin.Android 7.0 We testing switching to MONO_GC_PARAMS=bridge-implementation=old and this solved the problem.

Looks like the new Tarjan GC Bridge may be being a little too aggressive when cleaning up. We were wondering if the peculiarities of RecyclerView may also be connected to the problem.

We are happy to put together a sample project with a repro and post a bug report if this is useful.
Anyone else been seeing this issue?


Binding from code behind after Binding Context has been set

$
0
0

Im trying to bind a command that is located in the code behind. But the page already has the binding context set for all the other elements, and I don't want to include the command in the view model. How can I bind a property from the code behind after the data context has been set?

PayPal integration, xamarin forms shared project

$
0
0

Hi, I have a Xamarin forms shared project that has an Android and Windows phone project in it. I'm looking to integrate PayPal to simply make test sandbox payments, i.e. it wont be going live. This will be the first time I have attempted this, so I nothing of the process. Is there a plug in or package that I can add to my application?

also all and any How To's or guides would be greatly appreciated. I'm focused mostly on android integration with windows phone integration as a bonus.

Thanks in advance.

linking SDk and UserAssemblies Error inflating class android.support.v7.widget.FitWindowsFrameLayout

$
0
0

My app is working wihtout linking. It works fine also when I choose Sdk Assemblies only. It works fine in debug but it start failing if I choose linking SDk and UserAssemblies. I checked the logs and i find only what is below. I google all around for android, xamarin.android erros and people are talking about using Frames. I dont use any android native code. there is no frame defined in my android project. i am not sure if that is xamarin.forms producing but Can you please help me how to solve this problem?

    01-24 18:54:47.344: E/AndroidRuntime(30427): java.lang.RuntimeException: Unable to start activity ComponentInfo{myapp.myapp/md5874faab2802fcbafca06095cc637d65d.MainActivity}: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class android.support.v7.widget.FitWindowsFrameLayout
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.access$900(ActivityThread.java:154)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.os.Handler.dispatchMessage(Handler.java:102)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.os.Looper.loop(Looper.java:234)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.main(ActivityThread.java:5526)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at java.lang.reflect.Method.invoke(Native Method)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    01-24 18:54:47.344: E/AndroidRuntime(30427): Caused by: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class android.support.v7.widget.FitWindowsFrameLayout
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:410)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:309)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplV7.initWindowDecorActionBar(AppCompatDelegateImplV7.java:171)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:88)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:195)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:126)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at md5874faab2802fcbafca06095cc637d65d.MainActivity.n_onCreate(Native Method)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at md5874faab2802fcbafca06095cc637d65d.MainActivity.onCreate(MainActivity.java:32)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.Activity.performCreate(Activity.java:6285)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    ... 9 more
    01-24 18:54:47.344: E/AndroidRuntime(30427): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class android.support.v7.widget.FitWindowsFrameLayout
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    ... 22 more
    01-24 18:54:47.344: E/AndroidRuntime(30427): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.FitWindowsFrameLayout" on path: DexPathList[[zip file "/data/app/myapp.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/myapp.myapp-1/lib/arm, /data/app/myapp.myapp-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.createView(LayoutInflater.java:583)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    ... 24 more
    01-24 18:54:47.344: E/AndroidRuntime(30427):    Suppressed: java.lang.ClassNotFoundException: android.support.v7.widget.FitWindowsFrameLayout
    01-24 18:54:47.344: E/AndroidRuntime(30427):        at java.lang.Class.classForName(Native Method)
    01-24 18:54:47.344: E/AndroidRuntime(30427):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
    01-24 18:54:47.344: E/AndroidRuntime(30427):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
    01-24 18:54:47.344: E/AndroidRuntime(30427):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
    01-24 18:54:47.344: E/AndroidRuntime(30427):        ... 27 more
    01-24 18:54:47.344: E/AndroidRuntime(30427):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Entry/Editor text binding issue on ios when spellchecker autocorrect text

$
0
0

I found a possible bug on Entryand Editorcontrols on ios (XF v2.3.2.127). Try to enter some text with typo and then tap on "close" button on keyboard or just tap on another page content for hiding keyboard. In this case last value in view model which is binded to Textcontrol property is the text with typo, but you can see autocorrected text in control. DON'T tap on suggested word because in this case binding works fine.
On android everything works fine.
Can someone confirm this bug or describe this behavior?``

CachedImage FFImageLoading for Xamarin.Forms

$
0
0

https://github.com/molinch/FFImageLoading or https://github.com/daniel-luberda/FFImageLoading/ (new Forms features)

DEMO: https://github.com/daniel-luberda/FFImageLoading/tree/master/samples/ImageLoading.Forms.Sample

Caching support

The library automatically deduplicates similar requests: if 100 similar requests arrive at same time then one real loading will be performed while 99 others will wait. When the 1st real read is done then the 99 waiters will get the image.

Both a memory cache and a disk cache are present.

By default, on Android, images are loaded without transparency channel. This allows saving 50% of memory since 1 pixel uses 2 bytes instead of 4 bytes in RGBA (it can be changed).

WebP support

WebP is supported on both iOS and Android.

Downsampling

Downloaded images can be automatically downsampled to specified size (less memory usage). DownsampleHeight and DownsampleWidth properties

Retry

Downloads can be repeated if not succeeded: RetryCount and RetryDelay properties.

Placeholders support

  • LoadingPlaceholder

  • ErrorPlaceholder

image image

After this pull it'll also support Transformations!
https://github.com/molinch/FFImageLoading/pull/47

Transformations support

It doesn't modify original source images. Example:

  • RoundedTransformation

  • CircleTransformation

  • GrayscaleTransformation

image image

... and some more features. Feel free to test it. Not all features are on nuget yet (older version).

If APP close/kill (not running background), then it will can't receive notification.

$
0
0

Hello all,
I have a problem about receive notification. I use Xamarin.Form and use Azure Notification Hub Service to develop.
I wrote code in Droid.project, but if APP close/kill (not running background), then it will can't receive notification, 「 OnMessage(....) 」not work.

Anyone also had the same problem ? How can I solve it ?
Thanks !

MainActivity.cs


protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);
    global::Xamarin.Forms.Forms.Init(this, bundle);
    LoadApplication(new App());

    try
    {
        GcmClient.CheckDevice(this);
        GcmClient.CheckManifest(this);
        GcmClient.Register(this, Constans.SENDER_IDS);
    }
    catch (Java.Net.MalformedURLException)
    {
        CreateAndShowDialog("There was an error creating the client. Verify the URL.", "Error");
    }
    catch (Exception e)
    {
        CreateAndShowDialog(e.Message, "Error");
    }
}

GcmService.cs


[assembly: Permission(Name = "com.xForm.droid.permission.C2D_MESSAGE")]
[assembly: UsesPermission(Name = "com.xForm.droid.permission.C2D_MESSAGE")]
[assembly: UsesPermission(Name = "com.google.android.c2dm.permission.RECEIVE")]
[assembly: UsesPermission(Name = "android.permission.INTERNET")]
[assembly: UsesPermission(Name = "android.permission.WAKE_LOCK")]

namespace App5.Droid
{
    [BroadcastReceiver(Permission = Gcm.Client.Constants.PERMISSION_GCM_INTENTS)]
    [IntentFilter(new string[] { Gcm.Client.Constants.INTENT_FROM_GCM_MESSAGE },
        Categories = new string[] { "com.xForm.droid" })]
    [IntentFilter(new string[] { Gcm.Client.Constants.INTENT_FROM_GCM_REGISTRATION_CALLBACK },
        Categories = new string[] { "com.xForm.droid" })]
    [IntentFilter(new string[] { Gcm.Client.Constants.INTENT_FROM_GCM_LIBRARY_RETRY },
        Categories = new string[] { "com.xForm.droid" })]

    public class Constans : GcmBroadcastReceiverBase
    {
        public static string SENDER_IDS = ".....";
        public const string HUB_NAME = "....";
        public const string HUB_LISTEN_CONN = "....";
    }

    [Service]
    public class GcmService : GcmServiceBase
    {
        static NotificationHub azurenh;

        public GcmService() : base(Constans.SENDER_IDS){}

        public static void Register(Context Context)
        {
            GcmClient.Register(Context, Constans.SENDER_IDS);
        }

        public static void Unregister(Context Context)
        {
            GcmClient.UnRegister(Context);
        }

        protected override async void OnRegistered(Context context, string registrationId)
        {
            //....handle PNS, RegID data
        }

        protected override void OnUnRegistered(Context context, string registrationId)
        {
            if (azurenh != null)
                azurenh.Unregister();
        }

        protected override async void OnMessage(Context context, Intent intent)
        {
            var msg = new StringBuilder();
            // handle msg value.........

            string messageText = intent.Extras.GetString("message");
            string titleText = intent.Extras.GetString("title");
            if (!string.IsNullOrEmpty(messageText))
            {
                createNotification(titleText, messageText);
            }
            else
            {
                createNotification("Unknown message details", msg.ToString());
            }
        }

        void createNotification(string title, string desc)
        {
            var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;
            var uiIntent = new Intent(this, typeof(MainActivity));
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
            var notification = builder
                    .SetContentIntent(PendingIntent.GetActivity(this, 0, uiIntent, 0))
                    .SetSmallIcon(Android.Resource.Drawable.SymActionChat)
                    .SetTicker(title)
                    .SetContentTitle(title)
                    .SetContentText(desc)
                    .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                    .SetAutoCancel(true)
                    .Build();
            notificationManager.Notify(1, notification);
        }
    }
}

Does the Timed Local Notification functionality in the Local Notifications Plugin work on Windows?

$
0
0

Cross-posting from the Components forum, as that forum doesn't seem to get much attention...

Does the Timed Local Notification functionality in the Local Notifications Plugin work on Windows platforms (UWP and WinRT 8.1)? Other than setting the Toast capable property, is there anything else required? I am seeing the timed notifications on Android and iOS, but only the non-timed ones on Windows platforms.


How can I know when a view has finished rendering?

$
0
0

Hi guys-

I've noticed that when OnElementPropertyChanged is fired on a VisualElement like a BoxView, the properties of the underlying platform view are not updated at that time.

I want to know when the VisualElement's corresponding platform view is finished rendering, something like:

this.someBoxView.ViewHasRendered += (sender, e) => {
    // Here I would know underlying UIView (in iOS) has finished rendering
};

Looking through some code inside of Xamarin.Forms, namely VisualElementRenderer.cs, it would seem that I could raise an event after OnPropertyChanged has finished. Something like:

protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
    if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
        SetBackgroundColor(Element.BackgroundColor);
    else if (e.PropertyName == Layout.IsClippedToBoundsProperty.PropertyName)
        UpdateClipToBounds();
    else if (e.PropertyName == PlatformConfiguration.iOSSpecific.VisualElement.BlurEffectProperty.PropertyName)
        SetBlur((BlurEffectStyle)Element.GetValue(PlatformConfiguration.iOSSpecific.VisualElement.BlurEffectProperty));

    // Raise event
    VisualElement visualElement = sender as VisualElement;
    visualElement.ViewHasRendered();
}

Naturally there's a few more complexities to adding an event to the VisualElement class, as it would need to be subclassed. But I think you can see what I'm after.

While poking around I've noticed properties on VisualElement like IsInNativeLayout. But that only seems to be implementing in Win/WP8. Also, UpdateNativeWidget on VisualElementRenderer as well, however I can't figure out the proper way to leverage them.

Any ideas?
Much appreciated.

Plugin.Geolocator returns TaskCanceledException

$
0
0

Hello,

I am creating an app that keeps track of the users location.
Calling GetPositionAsync(); works for the first few times, but after a while it will always throw a TaskCanceledException.
Sometimes it will throw this error right away.

Has anyone else ran into this issue?

Thanks for the help!

How to design a ListView in Xamarin Forms like the image I've attached ?

Appearance in the iOS part of a Xamarin.Forms app

$
0
0

I'm trying to set the styling of an iOS app built in Xamarin.Forms. I would like to test out iOS styling. I have the code below. My button has a green background, but I can't get the text color of the buttons to be red. I'm just trying to test out if this work, and it doesn't seem to inspite of

https://developer.xamarin.com/guides/xamarin-forms/platform-features/ios/theme/#uiappearance

    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
    UIButton.Appearance.BackgroundColor = UIColor.Green;
    UIButton.Appearance.TintColor = UIColor.Red;
    UIButton.Appearance.SetTitleColor(UIColor.Red, UIControlState.Normal);

        global::Xamarin.Forms.Forms.Init();
        LoadApplication(new App());
    return base.FinishedLaunching(app, options);
    }

Any ideas on this are appreciated. Thanks!

Signature / Canvas component for Android/iOS/UWP

$
0
0

Hi @all!

I´m searching and searching the whole internet, and can´t get it done: i want something like the signature pad, but it has to work also with the UWP platform.
Is there any control / view / component out there which i can use?
The xamarin.controls.SignaturePad.Forms doesn´t work with UWP :-(

Greetings & thanks for every help!
Thomas

Viewing all 91519 articles
Browse latest View live