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

Adding Packages to Libraries used by Android, iOS, and UWP Head Projects

$
0
0

I am using Flurl.Http library (and BouncyCastle) in my Xamarin.Forms app I am building.
I am using .NetStandard 2.0, VS for Mac 7.5.3
These 2 are added to a project library that is used by Android, IOS and UWP head projects.

While Android and UWP projects can build just fine, iOS project fails to build due to error as per attached screenshot.
Adding these 2 libs to iOS head project as well, resolves the issue. I dont understand why is this needed for iOS but not for other
two head projects.


How to autosize Editor height?

$
0
0

I have an Editor control inside a Grid cell that I would like to automatically expand vertically as more text is entered.

Is this possible?

uploaded Video to sql and played in xamarin app

$
0
0

Hi Xamarin forum

I have a question how can I access my uploaded video in my database to my xamarin app Here is the current scenario

1 I have a backend program the is an asp.net with c# codebehind.
2. I have successfully uploaded my video and inserted it to my sql database
3. I have only inserted the video name and file path to database and the video is found in the uploaded vid directory
4. I m figuring how can I call that uploaded vid into my vidplayer in my xamarin app

Im stuck at num 4 can someone help me how to figure it out
I have tried so far the uploading video in asp.net c# but I still fail

How can I customize the color in switch?

$
0
0

I'm using xamarin.Forms and want to customize the color of the switch? I found on forum to customize the switch but it seems to be not working.
Below is the code :
[assembly: ExportRenderer(typeof(Xamarin.Forms.Switch), typeof(CustomSwitchRenderer))]
namespace EVGMobileSolution.Droid.Custom_Renderer
{
public class CustomSwitchRenderer : SwitchRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Switch> e)
{
base.OnElementChanged(e);

        if (Control != null)
        {
            //Control.TextOn = "Si";
            //Control.TextOff = "No";
            Android.Graphics.Color colorOn = Android.Graphics.Color.Maroon;
            Android.Graphics.Color colorOff = Android.Graphics.Color.LightGray;
            Android.Graphics.Color colorDisabled = Android.Graphics.Color.Gray;

            StateListDrawable drawable = new StateListDrawable();
            drawable.AddState(new int[] { Android.Resource.Attribute.StateChecked }, new ColorDrawable(colorOn));
            drawable.AddState(new int[] { Android.Resource.Attribute.StateEnabled }, new ColorDrawable(colorDisabled));
            drawable.AddState(new int[] { }, new ColorDrawable(colorOff));

            Control.ThumbDrawable = drawable;
        }
    }

}

Can anybody let me know what I'm missing here.

i need help with this error in plugin.media

$
0
0

only one operation can be active at a time xamarin

this is the code :

 public async void Agregar_Clicked(object sender, EventArgs e)
    {
        var cameraStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);
        var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage);

        if (cameraStatus != PermissionStatus.Granted || storageStatus != PermissionStatus.Granted)
        {
            var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera, Permission.Storage });
            cameraStatus = results[Permission.Camera];
            storageStatus = results[Permission.Storage];
        }

        if (cameraStatus == PermissionStatus.Granted && storageStatus == PermissionStatus.Granted)
        {
            var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
            {
                Directory = "Sample",
                Name = "test.jpg"
            });
        }
        else
        {
            await DisplayAlert("Permissions Denied", "Unable to take photos.", "OK");
        }

    }

Persistent warnings

$
0
0

What is the cause of these warnings?

I'm having these error because I trying to do this https://github.com/HoussemDellai/BottomBar-Xamarin-Forms, the most annoying part is it's persistence. I can't deploy my application because of these warnings.
I already clean and rebuild the solution, already update the package, already restart my IDE.

Can anyone explain this to me?
Thanks in advance :)

Xamamrin form : How to recieve notification from firebase console with image

$
0
0

I want to send notification to device token from firebase console with image, for example notification should be display like this.
Title
Body
Image // here is the issue i want to display image from url now when i get notification now i get url how i can convert url and display image.

My code for send notificaiton is this and i am sending from POSTMAN

{ "data":{
     "title":"New Notification!",
     "body":"Test\",
     "user_id": "1234",
        "image": "http://pngimg.com/uploads/google/google_PNG19645.png"
 },
"to" : "device_token" }

here is the image for notification i am currently getting and you can see clearly that i am getting url instead of image

enter image description here

Single Xaml entry to detect Phone number/Email id on entering the text

$
0
0

Hello Guys,

I'm developing a payment portal where the user has to confirm either phone number or email id to process the Payment. So, I'm planning to have single entry control which detects phone number/email id upon entering the text instead of having two separate entries to confirm phone number and email id.

Did anyone come across such situation?

Please suggest.


Compiling for iOS - will any mac do?

$
0
0

Hi,
I use windows/VS and have only targeted Android thus far but need to look at creating an iOS version of my app. As far as I understand things I will need to purchase a mac in order to do this but will any mac work? ie. can I get an old mac and still compile for the newer iOS versions?

Testing if a Label is Present

$
0
0

Hello! The UI testing has been giving me some problems and I'm not sure why it's being so difficult. Right now I'm trying to just check if a label is present on the page but after trying a few different ways still nothing. Here's the code I'm working with:

<?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="LogATourMobile.SignInPage"> <ContentPage.Content> <StackLayout Padding="20"> <Label Text="My App" FontSize="30" /> <Entry Placeholder="Email" Text="" Keyboard="Email" x:Name="emailField" TextChanged="OnFieldTextChanged" /> <Entry Placeholder="Password" Text="" IsPassword="true" x:Name="passwordField" TextChanged="OnFieldTextChanged" /> <Label Text="Sorry but your email or password could not be found" IsVisible="false" TextColor="Red" x:Name="errorMessage" /> <Button Text="Sign In" IsEnabled="false" x:Name="signInButton" Clicked="OnSignIn" /> <ActivityIndicator Color="White" IsRunning="false" IsVisible="false" x:Name="spinner" /> </StackLayout> </ContentPage.Content> </ContentPage>

[Test]
public void When_Sign_In_Unsuccessful_Show_An_Error()
{
    app.EnterText("Email", "bad@mail.com");
    app.EnterText("Password", "wrong");
    app.Tap("Sign In");

    var result = app.WaitForElement(e => e.Raw("label {text LIKE 'Sorry but'}"));
    Assert.AreEqual(result.Length, 1);
}

Every time I run this test it always says it found nothing but the label is definitely there on the page. Is there any other way to achieve this? I've tried using the Marked/Class query lookup methods but those aren't working either. I even set the StyleId and ClassId and still nothing. Am I just doing everything totally wrong? :)

Thanks for any help!

Update

Here's a screen shot of the app after the sign in fails.

Custom Renderer Not Working

$
0
0

So I've followed a YouTube video and the Microsoft docs on this but it still isn't working. I have a page with my custom renderer on it, which I've used the namespace for...
<local1:RoundedEntry Text="Test"/>

This comes from a .cs file

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Xamarin.Forms;

    namespace TestApp
    {
        public class RoundedEntry : Entry
        {
        }
    }

Then what exports to this file is this...

using Android.Content;
using TestApp;
using TestApp.Droid.CustomRenderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(RoundedEntry), typeof(RoundedEntryAndroid))]
namespace TestApp.Droid.CustomRenderers
{
    public class RoundedEntryAndroid : EntryRenderer
    {
        public RoundedEntryAndroid(Context context) : base(context)
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                Control.SetBackgroundColor(global::Android.Graphics.Color.LightGreen);
            }
        }
    }
}

I've tried this and I've tried downloading the example Entry Custom Renderer from https://developer.xamarin.com/samples/xamarin-forms/customrenderers/entry/ but it still doesn't work. I get no errors or warnings, but the application won't load the page with the custom renderer on it, it will crash. I'm not sure why it is crashing, I've updated to the latest Xamarin.Forms through Nuget. Also, it works if I remove the <local1:RoundedEntry Text="Test"/>

Anyone know of a fix? Thanks!

Edit: It works when deploying it to a device but not in the LivePlayer or Forms Previewer. It is a bit annoying to not be able to see what I'm doing.

How to automatically open soft keyboard when a new screen launches

$
0
0

I am trying to develop an app using xamarin.forms.
when my app launches there is an entry on the main screen
so I want to open keyboard automatically when my app launch.

ImageCircle package is not working in release mode in UWP

$
0
0

For the circle image, I am using Xam.Plugins.Forms.ImageCircle package and it is working fine in debug mode.

But in release mode, all the pictures are in square format. I uninstall and reinstall the nuget. Also, do clean, rebuild and deleting bin and obj folders, but still the issue is not resolved.

Thanks in advance

Xamarin Forms App Remote Connection to Mac OSX for iOS testing

$
0
0

I am trying to connect my Xamarin Forms app (which has been tested on Android only for the time being) with a Mac machine for iOS testing. The Windows 10 machine seems to be connecting to the Mac, in fact I always see the message saying successfully connected to the Mac computer name. After 5 seconds, Visual Studio simply closes on the Windows Machine with no error dialog. I do not see anything happening on the Mac.

I cant seem to find any visual studio logs (I also tried to open Visual studio in log mode). In the Windows Event viewer, however, I find this in the Applications log.

Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
at System.Enum+EnumResult.SetFailure(ParseFailureKind, System.String, System.Object)
at System.Enum.TryParseEnum(System.Type, System.String, Boolean, EnumResult ByRef)
at System.Enum.Parse(System.Type, System.String, Boolean)
at Xamarin.MacDev.PropertyListFormat+XmlFormat+Context.ReadObjectHead()

Windows Platform Details

Operating System: Windows 10 PRO Version 1803 (OS Build: 17134.165)

Microsoft Visual Studio Enterprise 2017 Version 15.7.4

Microsoft.NET Framework Version 4.7.03056

Xamarin - 4.10.10.2 (35a01d8dc)

Xamarin.iOS and Xamarin.MAC SDK - 11.12.0.4 (64fece5)

Mac OSX Platform Details

Operating System: macOS High Sierra Version 10.13.6

Visual Studio Community 2014 for Mac Version 7.5.4 (build 3)

Runtime: Mono 5.10.1.57 (2017-12/ea8a24b1bbf) (64-bit) GTK+ 2.24.23 (Raleigh theme) Xamarin.MAC 4.4.1.178 (master/ eeaeb7e60

Package version: 510010057

Xamarin Profiler Version 1.6.2

Apple Developer Tools X Code 9.4.1 (14161) Build 9F2000

Xamarin.MAC Version 4.4.1.193 (Visual Studio Community)

Xamarin.iOS Version 11.12.0.4 (Visual Studio Community)

Xamarin Inspector Version 1.4.0

IntentFilter on Android is not working for my file type

$
0
0

Hi,
I would like to share file from eg. Downloads folder in FileManager, to my application. My application uses files with my custom file extension: ".topo". I would like to open that but can't. My application is not listed in the list of applicaitons.

I added this code on top of MainActivity class decleration:

    [IntentFilter(new[] { Intent.ActionView, Intent.ActionEdit, Intent.ActionSend },
    Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
    DataScheme = "file",
    DataHost = "*",
    DataPathPattern = ".*\\\\.topo")]

When I use:
[IntentFilter(new[] { Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = @"application/pdf")]

It works perfectly.

What am I missing here? Filename is just numbers and letters.


How to add checkbox control in XAML

$
0
0

Hi,

I want to add Checkbox control in Xaml page. I added below code in .Xaml page.

    <CheckBox Margin="10, 10, 3, 3" 
                  Name="acceptPolicy" 
                  Content = "Accept our policy"
                  FontSize="12" 
                 Checked="CheckBox_Checked"/>

But i am getting below error?

Error CS0246: The type or namespace name 'CheckBox' could not be found (are you missing a using directive or an assembly reference?)

I am new to Xaml, since i am unable to find Checkbox control in Xamarin.Forms Xaml, i tried to use default Checkbox from here.

If some controls doesn't exist in Xamarin.Forms Xaml, whether can i use default Xaml controls or not?

2.3.0.107 iOS TranslateTo crashes

$
0
0

Hi all,

After some updates I'm getting the following exception when trying to animate element moves with TranslateTo:

An attempt was made to transition a task to a final state when it had already completed.

Code is:

    async void Shake(View view)
    {
        await view.TranslateTo(20, 0, 150, Easing.SinIn);
        await view.TranslateTo(-20, 0, 150, Easing.Linear);
        await view.TranslateTo(0, 0, 150, Easing.SinOut);
    }

What could be a reason of that?

Shake is invoked from UI thread.

Animating Navigation Bar properties on page transitions

$
0
0

I am looking to add a transition to navigation bar text when navigating between views in a MasterDetail layout. Just a simple fade out / in of the navigation page text.

I have implemented the below custom renderer, which is getting me 99% of the way.

The problem I am having is that it appears when calling PushASync method, the navigation bar text is being updated before the point that SetupPageTransition is called in the Custom NavigationPageRenderer. By debugging I can also see this text is updated before the outgoing pages OnDisppearing method is called.

I can't seem to find any way to trigger the animation before the text is updated, so at the moment the Push transitions behave strangely as it jumps to the new title before fading out. In reality, this was the reason I decided to add this transition in the first place, as I found this behaviour jumpy.

Is there anyway i can trigger this animation before the text is updated?

public class CustomNavigationPageRenderer : NavigationPageRenderer
{
    private Android.Support.V7.Widget.Toolbar toolbar;

    private Android.Support.V7.Widget.AppCompatTextView _textView;

    public CustomNavigationPageRenderer(Context context)
        : base(context)
    {
    }

    public override void OnViewAdded(Android.Views.View child)
    {
        base.OnViewAdded(child);
        if (child.GetType() == typeof(Android.Support.V7.Widget.Toolbar))
        {
            toolbar                     = (Android.Support.V7.Widget.Toolbar)child;
            toolbar.Elevation           = 0;
            toolbar.ChildViewAdded      += Toolbar_ChildViewAdded;
        }
    }

    private void Toolbar_ChildViewAdded(object sender, ChildViewAddedEventArgs e)
    {
        var view                    = e.Child.GetType();

        if (e.Child.GetType() == typeof(Android.Support.V7.Widget.AppCompatTextView))
        {
            var textView            = (Android.Support.V7.Widget.AppCompatTextView)e.Child;
            var font                = Typeface.CreateFromAsset(this.Context.Assets, "gothambold.ttf");
            textView.Typeface       = font;
            toolbar.ChildViewAdded  -= Toolbar_ChildViewAdded;

            _textView = textView;


        }
    }



    protected override void SetupPageTransition(Android.Support.V4.App.FragmentTransaction transaction, bool isPush)
    {

        HandleTextFade();

        base.SetupPageTransition(transaction, isPush);
    }

    private void HandleTextFade()
    {

        if(_textView != null)
        {
            var colorAnim = ObjectAnimator.OfInt(_textView, "textColor", Android.Graphics.Color.White, Android.Graphics.Color.Transparent);
            colorAnim.SetEvaluator(new ArgbEvaluator());
            colorAnim.SetDuration(250);
            colorAnim.Start();

            colorAnim.AddListener(new OMNIAnimListener(_textView));
        }

    }

}

public class OMNIAnimListener : AnimatorListenerAdapter
{
    Android.Support.V7.Widget.AppCompatTextView TextView;

    public OMNIAnimListener(Android.Support.V7.Widget.AppCompatTextView textView)
        : base()
    {
        TextView = textView;
    }

    public override void OnAnimationEnd(Animator animation)
    {

        var colorAnim = ObjectAnimator.OfInt(TextView, "textColor", Android.Graphics.Color.Transparent, Android.Graphics.Color.White);
        colorAnim.SetEvaluator(new ArgbEvaluator());
        colorAnim.SetDuration(250);
        colorAnim.Start();

        base.OnAnimationEnd(animation);
    }
}

ECG Graph

$
0
0

Hi,
I want to create Animated ECG Graph on Canvas by using Skiasharp in Xamarin.forms.
How to Draw Ecg graph on canvas?
Please Help.................................Thanks in Advance.

Login with google account

$
0
0

my app intent to use log in with google and facebook
facebook support webview but google did not support webview
can any one help me to use chrome custom tab in my app xamarin forms ?!

Thanks ;

Viewing all 77050 articles
Browse latest View live


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