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

ListView inside ListView Exception

$
0
0

Hi,

I am working on listview inside listview.
In iOS it's working fine.
But facing problem with android.
When scroll up/down crash the application
Error is : Unable to activate instance of type Xamarin.Forms.Platform.Android.ListViewAdapter from native handle 0xbe8ce1ec (key_handle 0xca27487).

Please help to solve this problem.


Help me with SQLite

$
0
0

I've been trying to figure out what's going wrong, but I can't.

I've modeled my SQLite usage based on the ToDoPCL project found on the xamarin documentation. As far as I can tell it is the same thing. One difference is that I'm using Prism when the example does not... But I'm not sure why that would matter.

12-13 16:23:49.296 D/Mono ( 4555): Config attempting to parse: 'System.Reflection.dll.config'. 12-13 16:23:49.296 D/Mono ( 4555): Config attempting to parse: '/usr/local/etc/mono/assemblies/System.Reflection/System.Reflection.config'. 12-13 16:23:49.296 D/Mono ( 4555): Assembly Ref addref SQLite-net[0xa7b26180] -> System.Reflection[0xa7b27740]: 7 12-13 16:23:49.300 D/Mono ( 4555): Assembly Ref addref SQLite-net[0xa7b26180] -> System.Reflection.Extensions[0xa7b28400]: 5 12-13 16:23:49.347 D/Mono ( 4555): DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so'). 12-13 16:23:49.347 D/Mono ( 4555): Searching for 'sqlite3_prepare_v2'. 12-13 16:23:49.356 D/Mono ( 4555): DllImport searching in: 'e_sqlite3' ('libe_sqlite3.so'). 12-13 16:23:49.356 D/Mono ( 4555): Searching for 'sqlite3_errmsg'. 12-13 16:23:49.392 F/ ( 4555): * Assertion at /Users/builder/jenkins/workspace/xamarin-android-d15-5/xamarin-android/external/mono/mono/mini/debugger-agent.c:4765, condition array->len == 1' not met
12-13 16:23:49.392 F/libc ( 4555): Fatal signal 6 (SIGABRT), code -6 in tid 4555 (ompanyname.BOTW)
`
There's a few lines of output when I try to run my project.

I get to these 2 lines:
database = new SQLiteAsyncConnection(dbPath);
database.CreateTableAsync().Wait();

And when it tries to create the table, it crashes.

Here's the project on my github: github.com/Evan-Coleman/BOTW

A login system in Xamarin.Forms?

$
0
0

Hello folks

I need to make a login system (connected to my sql server for username/pwd) but all i can find is tutorials for android or ios.
There is no such possibility to make a shared code for both systems?

I also would like to make the app stay connected on relaunch.
For that should i store the credentials (when they are correct) in some var (with akavache?) and relogin in background at every launch?

Thanks

Convert Image to byte[]

$
0
0

I've search for this but none of the options work for me. In the threads that I see, they are using BitmapImage or some .net assembly that does not exist in the pcl.

I have a xaml Image on the page & need to convert that image to a byte array so that I can store it in a blob.

Any help would be appreciated.

Steve.

to improve the droid performance

$
0
0

Hi,

I have a forms app that runs mostly image processing algorithms written in c# and located on a PCL file. At droid devices, my code runs 5 times slower compared to iOS. I choose the same CPU powered devices to do this test. I know that iOS building converts my code to %100 static native iOS code without any need for a JIT engine but Droid build doesn't do that and you must deploy a mono runtime also. Why Droid building also can't generate %100 static code for the platform? Is there any future plan to this?

Kind Regards,
Bulent.

tabbed page's tabs disappear

$
0
0

Hi,

another strange problem,

I have a navigation page, the root page of the navigation stack is Tabbed page,
after I push any page to the navigation stack and pop it, the tabbed page tabs dissapear

this problem shown after xamarin forms update

I did a layout but it's broken, doesn't work

$
0
0

I have this layout below, but it doesn't work. If i remove it and i uncomment the layout commented it works.
This layout below doesn't work:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Operacional"
             x:Class="Operacional.MainPage">

    <ContentPage.Content>

        <StackLayout VerticalOptions="Center">
            <StackLayout Orientation="Horizontal" HorizontalOptions="Center">
                <Label HorizontalTextAlignment="Center" Text="Notifications" FontSize="18"/>
                <local:Badge x:Name="BadgeNotifications" BoxColor="red"
                             WidthRequest="18" HeightRequest="18"
                             VerticalOptions="Center" HorizontalOptions="Center">
                    <x:Arguments>
                        <x:Double>30</x:Double>
                        <x:Double>10</x:Double>
                    </x:Arguments>
                </local:Badge>
            </StackLayout>

            <Button Text="Add Notification" Clicked="AddNotification"/>
        </StackLayout>
</ContentPage.Content>

</ContentPage>

The layout below work

<StackLayout Spacing="10" Orientation="Vertical" x:Name="Layout">

           <StackLayout HorizontalOptions="StartAndExpand" Orientation="Horizontal">
                <Entry x:Name="txtUser" FontSize="Small" WidthRequest="180" Placeholder="Id do Usuário"></Entry>
                <Entry x:Name="txtGaragem" FontSize="Small" WidthRequest="180" Placeholder="Id da Garagem"></Entry>
            </StackLayout>

            <StackLayout HorizontalOptions="Center" Orientation="Horizontal">
                <Button x:Name="btnWs"
                    HorizontalOptions="Center"
                    BackgroundColor="Gold"
                    HeightRequest="30"
                    WidthRequest="80"
                    Text="Web Service"
                    TextColor="Green"
                    FontSize="9" />
            </StackLayout>

            <StackLayout HorizontalOptions="Center" Orientation="Horizontal">

                <Button x:Name="btnFaturamento"
                    HorizontalOptions="End"
                    BackgroundColor="Gold"
                    HeightRequest="30"
                    WidthRequest="80"
                    Text="Faturamento"
                    TextColor="Green"
                    FontSize="9" />
                <Button x:Name="btnOcupacao"
                    HorizontalOptions="End"
                    BackgroundColor="Gold"
                    HeightRequest="30"
                    WidthRequest="80"
                    Text="Ocupação"
                    TextColor="Green"
                    FontSize="9" />
                <Button x:Name="btnTckCancelado"
                    HorizontalOptions="End"
                    BackgroundColor="Gold"
                    HeightRequest="30"
                    WidthRequest="100"
                    Text="Tic. Cancelados"
                    TextColor="Green"
                    FontSize="9" />
            </StackLayout>

        </StackLayout>

What am I doing wrong?

Replicating Android's "Secondary Order" drop-down ToolbarItem menu in iOS

$
0
0

Hello everyone!

I have been trying to replicate this:
htt ps://us.v-cdn.net/5019960/uploads/editor/j4/g4841e63uvo6.png
htt ps://us.v-cdn.net/5019960/uploads/editor/96/hkcgkiqwjoua.png

in IOS, in order for it to look like this:
htt ps://us.v-cdn.net/5019960/uploads/editor/3i/w4prr2qcfcsr.jpg

I came across this thread: htt ps://forums.xamarin.com/discussion/112957/content-page-secondary-toolbar-items-in-ios-same-as-android and he seems to have got an answer, but I have no idea how to implement what he has suggested.

Thank you so much for your time,
Daniel


How to add line breaks in a label in Xamarin Forms using XAML

$
0
0

I am trying to add line breaks to a label in Xamarin Forms using XAML, but it doesn't seem to work. This is the code I have right now that doesn't work:

<Label Text="All my text goes here etc\r\nawljfal alwef law fawlef lwemfalwfem" TextColor="White" WidthRequest="100" />

The '\r\n' actually outputs in the label text.

Input required :"keystoreAlias"

$
0
0

I'm trying to successfully build and deploy my forms application to hockey app.I'm using the default Xamarin.Android definition. I have run a succesful build before but now i want to be able to try out the deployed application (from hockeyapp) on my mobile phone so i selected the "sign the apk" checkbox and now despite the fact that i have provided the path to the keystore file, i'm still getting the error message on my build "Input required: keystoreAlias". Do i have to generate a new custom keystore file?

ACR BLE project build issues

$
0
0

Hi Guys,

I seem to be having issues using the bluetoothle library as it seems to be showing a warning message on build.

Warning NU1701: Package 'Plugin.BluetoothLE 2.0.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project. (NU1701)

Also when I try to build using an iPhone I get an error saying that its not compatible with my current SDK version 10.1 but certain features of bluetooth require version 11. I am assuming this is because Visual Studio seems to be loading it with the full .NET Framework version.

I have got the latest update on Visual Studio for Mac 2017 Community. I have also tried this on my updated VS 2017 and I get the same issue.

@AllanRitchie can you please shed some light on this issue and what I could be doing wrong.

Thanks

Entry loses focus when tapped

$
0
0

Help! The latest Android version seems to have some unwanted behaviour - Every time focus is put into an EntryCell or Entry, the keyboard pops up and loses focus on the entry cell. Has anybody else seen this behaviour?

How to open a different xaml page on push notification click event?

$
0
0

Hello,I want to open a different xaml page from android push notification click? But I have searched the forum and internet but cant find a working solution.Any ideas about how to achive this? (I'm using fcm integration in xamarin.forms project)

How do I use IValueConverters?

$
0
0

I have created a converter which looks like this:

public class SecondsToHoursMinutesValueConverter
    : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        var t = TimeSpan.FromSeconds((int)value);

        return string.Format("{0:D2} hours {1:D2} minutes", t.Hours, t.Minutes);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

Now I want to bind it with:

runtime.SetBinding(Label.TextProperty, new Binding("Runtime"), BindingMode.Default,
    new SecondsToHoursMinutesValueConverter(), null);

However, VS does not like it and says there is an error in that code:

Error 1 The type arguments for method 'Xamarin.Forms.BindableObjectExtensions.SetBinding(Xamarin.Forms.BindableObject, Xamarin.Forms.BindableProperty, System.Linq.Expressions.Expression<System.Func<TSource,object>>, Xamarin.Forms.BindingMode, Xamarin.Forms.IValueConverter, string)' cannot be inferred from the usage. Try specifying the type arguments explicitly. D:\git\Xam.Forms.Mvx\CoolBeans\CoolBeans\Pages\DetailedMoviePage.cs 101 13 CoolBeans

Xamarin Forms 2.5 and CreateFragment Extension.

$
0
0

Hello!

I have a question on the new Forms version in regards to how the fragment is created from the CreateFragment and CreateSupportFragment extension methods.

In the Xamarin.Forms.Platform.Android project in the AppCompat folder there is the PageExtensions.cs file. In this we can see the implementations for the EmbeddedSupportFragment and the EmbeddedFragment fragment classes. In my app, I'm seeing empty pages when I resume my app when I was last on one of my forms pages that I turned into a fragment, and I believe the cause is because the view for these fragments are passed into the fragment's constructors.

From what I know, derived fragment classes shouldn't create constructors because when the OS "resurrects" these fragments, it uses the parameter-less constructor, which in our case would make the ViewGroup empty.

I don't really post here much, so I this needs to be in a different thread please let me know. But I believe this may be an important issue for thos of us who would like to keep using this new api.


Customising Microcharts

$
0
0

I'm trying to achieve the chart similar to the attached screenshot and I'm almost there. The only problem is, how can I put values in each arc of the chart? I'm using Microchart library.

    void PopulateChart()
    {
        var data = new[]
        {
            new Microcharts.Entry(50)
            {
                ValueLabel = "50",
                Color = SKColor.Parse("#104950")
            },
            new Microcharts.Entry(70)
            {
                ValueLabel = "70",
                Color = SKColor.Parse("#F7A4B9")
            },
            new Microcharts.Entry(90)
            {
                ValueLabel = "90",
                Color = SKColor.Parse("#0084b4")
            }
        };

        this.chartView.Chart = new TemperatureChart() { Entries = data };
    }

using Microcharts;
using SkiaSharp;
using System;
using System.Linq;

namespace chart
{
    public class TemperatureChart : Chart
    {
        public TemperatureChart()
        {
            BackgroundColor = SKColor.Parse("#F6F1E9");
        }

        public float CaptionMargin { get; set; } = 12;

        public float LineSize { get; set; } = 18;

        public float StartAngle { get; set; } = -180;

        private float AbsoluteMinimum => Entries.Select(x => x.Value).Concat(new[] { MaxValue, MinValue, InternalMinValue ?? 0 }).Min(x => Math.Abs(x));

        private float AbsoluteMaximum => Entries.Select(x => x.Value).Concat(new[] { MaxValue, MinValue, InternalMinValue ?? 0 }).Max(x => Math.Abs(x));

        private float ValueRange => AbsoluteMaximum - AbsoluteMinimum;

        public override void DrawContent(SKCanvas canvas, int width, int height)
        {
            var sumValue = Entries.Sum(x => Math.Abs(x.Value));
            var radius = (Math.Min(width, height) - (2 * Margin)) / 2;
            var cx = width / 2;
            var cy = Convert.ToInt32(height / 1.25);
            var lineWidth = (LineSize < 0) ? (radius / ((Entries.Count() + 1) * 2)) : LineSize;
            var radiusSpace = lineWidth * 4;

            foreach (var entry in Entries.OrderByDescending(e => e.Value))
            {
                DrawChart(canvas, entry, radiusSpace, cx, cy, lineWidth);
            }

            DrawCaption(canvas, cx, cy, radiusSpace);
        }

        public void DrawChart(SKCanvas canvas, Entry entry, float radius, int cx, int cy, float strokeWidth)
        {
            using (var paint = new SKPaint
            {
                Style = SKPaintStyle.Stroke,
                StrokeWidth = strokeWidth,
                StrokeCap = SKStrokeCap.Round,
                Color = entry.Color,
                IsAntialias = true
            })
            {
                using (SKPath path = new SKPath())
                {
                    var sweepAngle = 180 * (Math.Abs(entry.Value) - AbsoluteMinimum) / ValueRange;
                    path.AddArc(SKRect.Create(cx - radius, cy - radius, 2 * radius, 2 * radius), StartAngle, sweepAngle);
                    canvas.DrawPath(path, paint);
                }
            }
        }

        private void DrawCaption(SKCanvas canvas, int cx, int cy, float radius)
        {
            var minimum = 0;
            var medium = Math.Round(Entries.Max(e => e.Value) / 2);
            var maximum = Entries.Max(e => e.Value);

            canvas.DrawCaptionLabels(string.Empty, SKColor.Empty, $"{minimum}°", SKColors.Black, LabelTextSize, new SKPoint(cx - radius - LineSize - CaptionMargin, cy), SKTextAlign.Center);
            canvas.DrawCaptionLabels(string.Empty, SKColor.Empty, $"{medium}°", SKColors.Black, LabelTextSize, new SKPoint(cx, cy - radius - LineSize), SKTextAlign.Center);
            canvas.DrawCaptionLabels(string.Empty, SKColor.Empty, $"{maximum}°", SKColors.Black, LabelTextSize, new SKPoint(cx + radius + LineSize + CaptionMargin, cy), SKTextAlign.Center);
        }
    }
}

Detect and Open another App on device

$
0
0

Can someone tell me the best approach to accomplishing this for IOS and Android. Code samples or links to related discussions would be most appreciated.

thanks

Given Key Not Present in Dictionary Xamarin Forms

$
0
0

I Have a Login ViewModel something like this below

public class LoginViewModel : ViewModelBase
    {

        private readonly IAuthenticationService _authenticationService;

        public LoginViewModel(IAuthenticationService authenticationService)
        {
            _authenticationService = authenticationService;
        }
  }

And i'm Binding like this in XAML

<ContentPage.BindingContext>
    <viewModels:LoginViewModel />
</ContentPage.BindingContext>

When i Compile i'm getting "Given Key Not Present in Dictionary"

But when i add an Empty Constructor to My ViewModel like this

      public LoginViewModel ()
            {

            }

It working fine ,so is there any workaround for this other than instantiating from Code behind of my ViewPage ?

Is there how to debug xaml?

$
0
0

I have a xaml file and this file doen't work. But i don't know what's happening, then i ask: Is there how to debug this file? I need to know where is broken, where is issue. I use Visual Studio 2017 and Xamarin.Forms

xamarin forms linker and prism.dryioc

$
0
0

Soo, when we use Xamarin Forms, we want a small apk size. To achieve that we have Linker and Proguard.
But using Prism.Dryioc I got stuck, I really don't know how to properly setup my Link configuration file.

With this file(linker configuration) I just got a "System.TypeInitializationException: The type initializer for 'Registry' threw an exception."
Can someone help me to find the way to make Linker works?

Viewing all 79144 articles
Browse latest View live


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