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

TargetFrameworkVersion v7.0 could not be converted to an Android API level. Xamarin.Forms (Portable)

$
0
0

I have created new Xamarin.Forms (Portable) application and tried to build but I am getting the error

TargetFrameworkVersion v7.0 could not be converted to an Android API level. Xamarin.Forms (Portable)
Please check the attached screenshot. Please check the attached image.

Are there any solutions for this?


Is there nay way of cancelling the "back" button event from the NavigationPage?

$
0
0

Topic.

Is there any way of cancelling the "back" button event from the NavigationPage, preventing the user from popping the navigation stack ?

I already can intercept the hardware back button from the main activity, but I wasn't able to capture the navigation back button.

WebView.Eval not call javascript function inside my HTML

$
0
0

Hi guys, I'm trying to use the Eval function of the WebView control to run a javascript function into my WebView. The WebView loaded correctly my HTML with the Javascript function, but when I use WebView.Eval(javascript_function), nothing happens and the function is not called.
Here my CS code:

 var _Script = string.Format("enableBeacon(\"{0}\") ", id);
            _WebViewMap.Eval(_Script);

Here my Xaml:

<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<WebView x:Name="WebViewMap" WidthRequest="1000" HeightRequest="1000" Source="{Binding HtmlSource.HtmlUrlSource}"/>
</StackLayout>

Here my Javascript function:

 function enableBeacon(id)
 {
     var myBeacon = document.getElementById(id);
     myBeacon.style.display = "";
    alert("I am an alert box!");
 }

Thanks in advance

Resource.String does not contain a definition for Application name

$
0
0

I am getting the following error after updating of this Xamarin.Android.Support.v7.AppCompat
Resource.String does not contain a definition for Application name
Resource.String does not contain a definition for Hello

How to mix the pinch and pan gesture for image control together?

$
0
0

I try to mix the pinch and pan gesture code (https://developer.xamarin.com/samples/xamarin-forms/WorkingWithGestures/PinchGesture/ and https://developer.xamarin.com/samples/xamarin-forms/WorkingWithGestures/PanGesture/) for my image control but failed. The image just acting weirdly while zooming/panning. I think some of the code are conflicting in the OnPinchUpdated and OnPanUpdated fucntions.

My PinchToZoomAndPanContainer class is shown below:

public class PinchToZoomAndPanContainer : ContentView
    {
        double currentScale = 1;
        double startScale = 1;
        double xOffset = 0;
        double yOffset = 0;
        double x, y;

        public PinchToZoomContainer()
        {
            var pinchGesture = new PinchGestureRecognizer();
            pinchGesture.PinchUpdated += OnPinchUpdated;
            GestureRecognizers.Add(pinchGesture);

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

        void OnPinchUpdated(object sender, PinchGestureUpdatedEventArgs e)
        {
            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 = Content.Scale;
                Content.AnchorX = 0;
                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);

                // The ScaleOrigin is in relative coordinates to the wrapped user interface element,
                // so get the X pixel coordinate.
                double renderedX = Content.X + xOffset;
                double deltaX = renderedX / Width;
                double deltaWidth = Width / (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 = Content.Y + yOffset;
                double deltaY = renderedY / Height;
                double deltaHeight = Height / (Content.Height * startScale);
                double originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight;

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

                // Apply translation based on the change in origin.
                Content.TranslationX = targetX.Clamp(-Content.Width * (currentScale - 1), 0);
                Content.TranslationY = targetY.Clamp(-Content.Height * (currentScale - 1), 0);

                // Apply scale factor
                Content.Scale = currentScale;
            }
            if (e.Status == GestureStatus.Completed)
            {
                // Store the translation delta's of the wrapped user interface element.
                xOffset = Content.TranslationX;
                yOffset = Content.TranslationY;
            }
        }


        void OnPanUpdated(object sender, PanUpdatedEventArgs e)
        {
            switch (e.StatusType)
            {

                case GestureStatus.Running:
                    // Translate and ensure we don't pan beyond the wrapped user interface element bounds.
                    Content.TranslationX = Math.Max(Math.Min(0, x + e.TotalX), -Math.Abs(Content.Width - App.ScreenWidth));
                    Content.TranslationY = Math.Max(Math.Min(0, y + e.TotalY), -Math.Abs(Content.Height - App.ScreenHeight));
                    break;

                case GestureStatus.Completed:
                    // Store the translation applied during the pan
                    x = Content.TranslationX;
                    y = Content.TranslationY;
                    Debug.Write("x=" + x.ToString() + "   y=" + y.ToString());
                    break;
            }
        }
    }

I noticed that the way to instantiate this PinchToZoomAndPanContainer class is a little bit different in the sample code from my above hyperlinks, pinch is put in a Grid, while pan is put in an AbsoluteLayout. I tried both for my code, but neither works. I would really appreciate it very much if someone can help me fix it.

How to Center a Layout inside another Layout?

$
0
0

So I have Two Layouts . Relative and Stack. Stack is the Child of Relative. So I want to vertically center the Stack relative to the Parent Layout. How to do it?

How to make a StackLayout or Layout clickable

$
0
0

I have multiple StackLayouts inside a horizontal ScrollView inside a ViewCell. I have two questions:

  1. How to make StackLayout clickable?
  2. How to Call Navigation.PushAsync(Page) inside ViewCell class? I can call Navigation.pushAsync(Page) from ListView tho.

Thank you.

don't vision my x:name in class.

$
0
0

Hi. I can't do that my x:Name="tapAdd" has vision in class.

<ListView x:Name="listItems">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
*content*
<Image ...>
<Image.GestureRecognizers>
<TapGestureRecognizer x:Name="tapAdd"/>
</Image.GestureRecognizers>
</Image>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>


Could not find file obj/iPhoneSimulator\Debug\xxxxxx.exe.manifest

$
0
0

Hi
Today I Installed Xamarin iOS Simulator (for Windows) . When I start debug (Debug - IPhoneSimulator - IPhone 5s iOS 9.3) i get following message now:
Could not find file obj/iPhoneSimulator\Debug\xxxxxx.exe.manifest.

There is no manifest file in the directory. How can i force VS to create one ? When I disable remote Simulator on Windows i get the same error now.

Setup
VS 14.0.25425.01 Update 3
Xamarin 4.1.2.18
Xamarin.IOS 9.8.2.22
Xamarin.Forms 2.3.0.107

When can I use Xamarin.Android.Support.* v25 in a Forms project?

$
0
0

I'd like to use Xamarin.Android.Support.Design version 25, with useful new views like BottomNavigationView, in my Xamarin.Forms project. Xamarin.Forms however locks the support libraries at version 23.3.0. I saw that a pull request was just merged that should fix this for the May release of Visual Studio:

https://github.com/xamarin/Xamarin.Forms/pull/679

Will there be a way to use v25 in my project earlier than that?

ELCImagePicker await a handler

$
0
0

Hi,

I'm trying to use ELCImagePicker but i want to await the results. I definitely missing something here as the flow of this code isn't correct. It returns a null FileData object, before hopping back into the handler and effectively doing nothing since the null result is already returned.

        public async Task<FileData> PickFile()
        {

            FileData f = new FileData();

            var picker = ELCImagePickerViewController.Create();
            picker.MaximumImagesCount = 3;
            picker.Completion.ContinueWith(t => {
                if (t.IsCanceled || t.Exception != null)
                {
                    // no pictures for you!
                }
                else
                {
                    var items = t.Result as List<AssetResult>;
                    var first = items.First();

                    f.FileName = first.Name;
                    f.Path = first.Path;

                    var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), f.FileName);

                    first.Image.AsJPEG().Save(path, false);

                    f.StreamGetter = () => File.OpenRead(f.Path);

                }
            });

            UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(picker, true, null);

            await picker.Completion;

            return f;
        }

Any tips where i'm messing up

Thanks
Peter

How to resize image file on Xamarin.forms. (+ writeableBitmap package can't be added)

$
0
0

I'm making iOS and Android app using with Xamarin.forms. (PCL project)

I need to resize my image file from 'MediaFile class' that is returned from 'CrossMedia.Current.PickPhotoAsync ()'.

What's your best way to do it?

and I have searched long time and noticed that many people uses 'writeableBitmap'.
But this 'writeableBitmap' nuget package can not be added because Xamarin platform is updated?

How Can i Solve This Problem?

How can i set the focus on Dynamic Entry control

$
0
0

foreach ( var item in Entries)
{
NumericEntry entryObj = new NumericEntry();
entryObj.Completed += (s, e) => entryObj.Focus();

}

Here how can i set the focus on next entry object. can we achieve this based on entryObj id.

Rare random crashes in 2.3.4 pre1: NRE at Xamarin.Forms.VisualElement.Finalize()

$
0
0

Edit: Created bug report - https://bugzilla.xamarin.com/show_bug.cgi?id=51685

Since having updated to XF 2.3.4-pre1 yesterday, I've had multiple hard crashes when triggering navigation from one page to the other (from different pages). All I'm seeing in the HockeyApp crash report are those NullReferenceExceptions:

android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.VisualElement.Finalize()

I can reliably reproduce this if I just navigate back and forth often enough - eventually, it crashes after the button tap that triggers the navigation to the child page. When running in debug mode, the debugger doesn't give me anything. The app just dies.

This has showstopper quality - I hope the issue already sounds familiar to you.

Thanks,
Philipp


How to pop the current page in xamarin forms?

$
0
0

I've created the Xamarin forms project. I have created the master detail page and the other pages. I want to pop the current page so that I can go back to the previous page. I've used the below code:

await Navigation.PopAsync();

This works in Android but sometimes it crashes the iOS app in strange behaviour. When I move around in the app then in many pages sometimes when the PopAsync is called the content is removed and page goes blank but the page don't get back to the previous page and when I press he back button the app crashes. I've tried to catch the error but the error comes (null). How can I pop the page then?

How to add Icon in front of Entry

Problems with Focus()

$
0
0

Hello everyone!

I have this code:

public void recibeCodigoArticulo()
        {
            //Si la respuesta del MessagingCenter es "envio" pone como parametro strCodigo
            MessagingCenter.Subscribe<xamlPedido, string>(this, "CodigoArticulo", (sender, strCodigo) =>
            {
                DisplayAlert("Prueba","Entro recibe mensaje","OK");
                if (strCodigo != "")
                {
                    txtArticulo.Text = strCodigo;
                    clsGlobal.gblStrCodigo = "";
                    if (txtArticulo.Text.Trim() != "")
                    {
                        this.txtCantidad.Focus();
                        buscaArticulo();
                        buscaCantidad();
                        actualizaUnidad();
                    }
                }
            });
        }

The code works fine, but the .Focus () method does not display the keyboard, someone knows it can happen, because I have this same method on another screen and if it does, only in this one.

Xamarin form template is not showing in the visual studio 2015 new projects templates

$
0
0

Xamarin form template is not showing in the visual studio 2015 new projects templates

Is it possible to add a banner advertising to my xamarin.forms app?

$
0
0

I could not find a solution for banner implementation. The api from admob does not work for windows phone or uwp. Also i can not add a banner via admob or anything with the pcl project. The banner will be shown always at the bottom of the app. I would like to develop the ui in xaml in the pcl project. I found a discussion with a custom renderer. But it was not a banner advertising. Is it possible to add a advertising in a xamarin.forms app for all plattforms or at least for android and apple?

Viewing all 91519 articles
Browse latest View live


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