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

app crashing while implementing the qr code scanner

$
0
0

Can anyone please help me on this? While implementing the qr code scanner app is crashing. below process i followed i used Zxing plun for that after click on the image the camera opened and it s scanning and getting the result. after click on the image it will open the camera from there if i click on the back button app is crashing. i tried onbackbuttonpressed event. but no use.

Thanks in advance.


2 Line Label with Tail Truncation

$
0
0

I'm converting a MonoTouch.Dialog app to Xamarin.Forms.

I have a Cell in a ListView and that has a "Detail" line that should be 2 lines long, and should truncate the tail after that.

        var lblDetail = new Label
        {
            LineBreakMode = LineBreakMode.TailTruncation,
            Text = "a really long string that should show 2 lines then ..."
        };

How do I set something like, "Lines = 2"

Forms Buttons and SKCanvas with TouchEffect?

$
0
0

I am currently using SkiaSharp along side a TouchEffect based on the fingerpainting sample and have come across an issue where button clicks are not always fired when a user actually taps a button, they do fire if you repeatedly press the button but it isnt reliable.

Has anyone else experienced this issue? Any known solutions?

Turn on location services without navigating to settings page?

Error on build app iOS, only on the production URL (https) :TrustFailure (One or more errors occu...

$
0
0

I have a problem when build my iOS project, only on the url production(for communication to web service). I think so wich the problem is the protocol HTTPS but i don't find any solution for this.My output:

P.S.: My HttpClient Implementation in iOS Build, is configured Managed(default)

System.Net.Http.HttpRequestException:

Thread finished: #10
The thread 0xa has exited with code 0 (0x0).
Thread finished: #11
The thread 0xb has exited with code 0 (0x0).
Thread finished: #6
The thread 0x6 has exited with code 0 (0x0).
2018-03-28 04:34:13.362 AppNivel.iOS[4830:44384]
Unhandled Exception:
System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: TrustFailure (One or more errors occurred.) ---> System.AggregateException: One or more errors occurred. ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> Mono.Security.Interface.TlsException: CertificateUnknown
at Mono.AppleTls.AppleTlsContext.EvaluateTrust () [0x000ca] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/Mono.AppleTls/AppleTlsContext.cs:269
at Mono.AppleTls.AppleTlsContext.RequirePeerTrust () [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/Mono.AppleTls/AppleTlsContext.cs:210
at Mono.AppleTls.AppleTlsContext.ProcessHandshake () [0x00046] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System/Mon
o.AppleTls/AppleTlsContext.cs:186
at ...

at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at AppNivel.iOS.Application.Main (System.String[] args) [0x00001] in D:\AppNivel_Bkp_14032018_1450h\AppNivel\AppNivel.iOS\Main.cs:17
2018-03-28 04:34:13.366 AppNivel.iOS[4830:44384] Unhandled managed exception:
An error occurred while sending the request (System.Net.Http.HttpRequestException)
at System.Net.Http.HttpClientHandler+d__64.MoveNext () [0x0046c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:406
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/msco
rlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at ...

2018-03-28 04:34:13.401 AppNivel.iOS[4830:44384] critical:

Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries

used by your application.

The app has been terminated.

Listview detect scroll state

$
0
0

How to detect scroll state in xamarin forms listview?
Similar approch in android with OnScrollStateChanged

Curved corners in tableview cells

$
0
0

Is it possible to have cells with curved corners displayed in a tableview? If so would anyone know how to go about it?

GET webdata - Working on UWP, Android not building connection

$
0
0

I've been requesting some DATA using the a nuget plugin (Binance.NET) in my shared Project. Works flawlessly on UWP aswell as a .net core and asp.net application i am running but for some reason on android debugging it can not get the data.

It throws following error when using it in the constructor or calling the data later on through a button.
"Web error: No response from server"

Is there a obvious Android behaviour that i am not familiar with and am ignoring?


binding data to the background image property of a content page

$
0
0

i want to bind data dynamically to the background image property of a content page from my api.
can anyone suggest me how i can achieve that .... Thanks in advance

Transaction not found with paypal payments on Paypal.Forms

$
0
0

Here I am implementing Paypal.Forms. in xamarin forms
when a user proceed payments then it will show successfull transaction with Id,while checking on buyer paypal sandbox acount then it will nothing to show transactions.
var result = await CrossPayPalManager.Current.Buy(new PayPalItem("Test Product", new Decimal(10.00), "USD"), new Decimal(SaleAmonut));
if (result.Status == PayPalStatus.Cancelled)
{
await DisplayAlert("Message", "Payment Cancelled", "OK");
}
else if (result.Status == PayPalStatus.Error)
{
await DisplayAlert("Message", result.ErrorMessage, "OK");
}
else if (result.Status == PayPalStatus.Successful)
{
await DisplayAlert("Message", "Your Transaction id: "+result.ServerResponse.Response.Id, "OK");
}

and how to find "YOUR ID STRING" and MarchantName from paypal account?
CrossPayPalManager.Init(new PayPalConfiguration(PayPalEnvironment.NoNetwork, "YOUR ID STRING")
{
//If you want to accept credit cards
AcceptCreditCards = false,
//Your business name
MerchantName = "test facilitator",
//Your privacy policy Url
MerchantPrivacyPolicyUri = "https://www.example.com/privacy",
//Your user agreement Url
MerchantUserAgreementUri = "https://www.example.com/legal"
},this
);

Unable to Open PDF into the third-party app

$
0
0

Hi,

I am downloading file into download folder. A pdf file is downloaded properly but unable to open into third-party app.

  1. If I select Target SDK : Automatic into the droid then it works perfectly. I am able to show pdf file with the third-party app. But with this selection, I can't publish app on the play store. It throws an error Target SDK should be 23 or greater.

  2. If I select Target SDK other than automatic then it's not allowing to open PDF file into the third-party app.
    Please see my code below.

public void OpenFile(string filePath)
{
string externalStorageState = global::Android.OS.Environment.ExternalStorageState;
string application = "";

        string extension = System.IO.Path.GetExtension(filePath);

        switch (extension.ToLower())
        {
            case ".doc":
            case ".docx":
                application = "application/msword";
                break;
            case ".pdf":
                application = "application/pdf";
                break;
            case ".xls":
            case ".xlsx":
                application = "application/vnd.ms-excel";
                break;
            case ".jpg":
                application = "image/jpeg";
                break;
            case ".jpeg":
                application = "image/jpeg";
                break;
            case ".png":
                application = "image/png";
                break;
            default:
                application = "*/*";
                break;
        }
        //var externalPath = global::Android.OS.Environment.ExternalStorageDirectory.Path + "/report" + extension;
        //File.WriteAllBytes(externalPath, bytes);

        //Java.IO.File file = new Java.IO.File(externalPath);
        Java.IO.File file = new Java.IO.File(filePath);
        file.SetReadable(true);
        //Android.Net.Uri uri = Android.Net.Uri.Parse("file://" + filePath);
        Android.Net.Uri uri = Android.Net.Uri.FromFile(file);
        Intent intent = new Intent(Intent.ActionView);
        intent.SetDataAndType(uri, application);
        intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);

        try
        {
            Xamarin.Forms.Forms.Context.StartActivity(intent);
        }
        catch (Exception)
        {
            Toast.MakeText(Xamarin.Forms.Forms.Context, "No Application Available to View this file.", ToastLength.Short).Show();
        }
    }

The code is crashing on this line Xamarin.Forms.Forms.Context.StartActivity(intent);

Please help me.

Custom Template for last cell in a listView

$
0
0

Hello,
I need to have a custom template for the last view cell (and for some other cells). So I need to get the list count in my DataTemplateSelector.
I tried
<ListView x:Name="StatusList" ItemsSource="{Binding ListStatus}" SeparatorVisibility="None" HasUnevenRows="True"> <ListView.ItemTemplate> <interfaces:SuiviDataTemplateSelector x:Key="SuiviDataTemplateSelector" TemplateEmpty="{StaticResource TemplateEmpty}" TemplateMessage="{StaticResource TemplateMessage}" TemplateFinal="{StaticResource TemplateFinal}" ListViewLength="{Binding Source={x:Reference Name=StatusList},Path=BindingContext.ListStatus.Count}"/> </ListView.ItemTemplate> <ListView.RowHeight> <OnIdiom x:TypeArguments="x:Int32" Phone="100" Tablet="120"/> </ListView.RowHeight> </ListView>
but it dosen't work I get the "Position xx:yy. No property, bindable property, or event found for 'ListViewLength', or mismatching type between value and property. " error.

And my selector:
`class SuiviDataTemplateSelector : DataTemplateSelector
{
public DataTemplate TemplateMessage { get; set; }
public DataTemplate TemplateEmpty { get; set; }
public DataTemplate TemplateFinal { get; set; }
public int ListViewLength { get; set; }

    protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
    {
        var listView = container as ListView;
      //  var statusList = listView.Parent as 

        if (((StatutSuivi)item).Id >= ListViewLength)
            return TemplateFinal;
        else
        {
            if (((StatutSuivi)item).Done == false)

                return TemplateEmpty;
            else
                return TemplateMessage;
        }

    }
}`

Can anyone help?

Xamarin.Forms and Azure IoT Hub

$
0
0

Greetings!

I have several applications that need to send messages to Azure IoT Hub. One is UWP, and others are Xamarin.Forms apps (UWP and Android).

The UWP app works perfectly, I used Microsoft.Azure.Devices.Client in it to send messages. Also, the Xamarin.Forms UWP works as well. Problem is Android. Android app builds, but when I deploy it - it just shows a white screen.

I used Microsoft.Azure.Devices.Client NuGet package in all of them. Should I use a different NuGet package for Xamarin.Forms? Did I miss something?

I didn't try using Microsoft.Azure.Devices.Client.PCL. Should I try using it? Xamarin.Forms (UWP and Android) and UWP app are supposed to reference the same submodule, which contains code for sending messages to Azure IoT Hub.

Problems closing App

$
0
0

I have a Xamarin.Forms macOS app, and can't close it with the shortcut cmd+q. Nothing append.
Do I need to implement a menu for this, or not?

Cross Platform App(Xamarin.Forms) Applet is missing

$
0
0

I have installed visual studio 2017 enterprise edition windows 10. I also installed below tools.
.NET Development Development
Universal WIndows Platform development
ASP.net and web development
Mobile development with JavaScript

Since Cross Plateform App(Xamarin.Forms) is not avaliable, I am not able to follow xam-120 class and unable to create Cross Platform App(Xamarin.Forms). I am new to Xamarin, it's very hard to follow calss when you don't have same tools available as instructed in te class.

In my C# Cross Platemform, I have only two templates available as below.
1) Mobile App(Xamarin.Forms)
2) UI Test App(Xamarin.UITest | Cross-Platform)

Thank you.


Can I include other xaml files from App.xaml?

$
0
0

I have a long list of styles in my App.xaml ResourceDictionary, I was wondering if i could split them into separate smaller xaml files and then include them from App.xaml.
If it's possible, can you point me to a tutorial, or show me a little code snippet?

Thanks!

No auto generated events from .xaml file in .xaml.cs file

$
0
0

Hello everyone,

I have a test.xaml file and his corresponding test.xaml.cs file in my common xamarin project.
When I add a "Clicked='MyHandler'" option on a tag in my test.xaml file, VS doesn't generate the code for the event in test.xaml.cs file...

I'm really stuck with this issue...


Offline Map using MapBox with Xamarin.Forms(Shared).Android

$
0
0

I am working to create a Moblie APP for iOS and Android using Xamarin.Forms(Shared) project. Using MAPBox SDK and some GeoJSON coordinates, I have created a sample which can show the Polyline and Polygon.
I am looking for some sample code for Xamarin.Forms(Shared).Android which can provide the feature of offline maps and using that Offline map and GeoJSON data, I can draw the Polyline and Polygon.
Can you provide some sample code which can fulfill our requirement?

Prism: Back button on Android closes app when popup is open

$
0
0

Hello everyone,

I was working with popups in Prism. With the following code:

_navigationService.NavigateAsync(nameof(TestPopup));

The popup is added to the navigation stack. Therefore, I expect it go to the previous page when pressing the Android hardware back button. Too bad, it doesn't, it just closes the app (because there is nothing more in the navigation stack?)

Here is a test project where I reproduced it in:
https://github.com/GyllionElderen/PrismPopupTest

Does anyone know what to do to make the app go back to the root page instead of closing the app?

Xamarin Forms Sockets

$
0
0

I don't get it, my friend and I are developing an API and our WebSocket services works, but not the mobile side.. I tried with a couple of clients, on the web, our echo messaging and everything works.

The thing is, I mean, the things seem like the socket is mono-directional. I tried the example of https://github.com/rdavisau/sockets-for-pcl#a-tcp-client:

var address = "127.0.0.1";
var port = 11000;
var r = new Random(); 

var client = new TcpSocketClient();
await client.ConnectAsync(address, port);

// we're connected!
for (int i = 0; i<5; i++)
{
    // write to the 'WriteStream' property of the socket client to send data
    var nextByte = (byte) r.Next(0,254);
    client.WriteStream.WriteByte(nextByte);
    await client.WriteStream.FlushAsync();

    // wait a little before sending the next bit of data
    await Task.Delay(TimeSpan.FromMilliseconds(500)); 
}

await client.DisconnectAsync();

First, after I get connected with this :

public async void ConnectSocketToAPIAsync()
    {
        SocketClient = new TcpSocketClient();
        await SocketClient.ConnectAsync("my.ws.service", 4242);
        ActiveSocketExchange();
    }

    public async void ActiveSocketExchange()
    {
        var bytesRead = -1;
        var buf = new byte[1];

        while (bytesRead != 0)
        {
            bytesRead = await SocketClient.ReadStream.ReadAsync(buf, 0, 1);
            if (bytesRead > 0)
                MessagingCenter.Send((App)Current, SOCKET_Message, System.Text.Encoding.UTF8.GetString(buf, 0, bytesRead));
        }
    }

Everything's fine, my TcpClient is well initialized (even the web-link becomes the http's API addr)

From my page view, when I'm done writing my text, I'm pressing the done button of the keyboard and this code is called:

private void InitSocketPart()
    {
        MessagingCenter.Subscribe<App, string>((App)Application.Current, App.SOCKET_Message, (sender, text) =>
        {
            SocketResponseText = text;
        });
    }

    private async void OnTextCompleted(object sender, EventArgs ea)
    {
        var bytes = Encoding.UTF8.GetBytes(TextToSend);
        try {
            if (App.SocketClient.WriteStream.CanRead)
                Debug.WriteLine("canRead");
            if (App.SocketClient.WriteStream.CanWrite)
                Debug.WriteLine("canWrite");

            App.SocketClient.WriteStream.Write(bytes, 0, TextToSend.Length);
            App.SocketClient.WriteStream.Flush();
        } catch (Exception e)
        {
            Debug.WriteLine(e);
        }
    }

So now CanWrite && CanRead are true, but nothing at all happens, even with the use of Async methods... Why so? I don't get it..

The use of messaging center is just to have only one point of incoming message. I'm using it for other things and it works perfectly :)

Thank for any help..

Viewing all 77050 articles
Browse latest View live


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