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

Keep getting Default value didnt match return type error

$
0
0

Hi,

I try to use CarouselViewControl from @alexrainman while implementing a MVVM pattern.
Although everything seems ok, I keep getting this error "Default value did not match return type. Parameter name: defaultValue (ArgumentException)".

My Model:

public class TabbedPageIconModel
{
        public Xamarin.Forms.Image MyImage { get; set; }
        public string MyImageURL { get; set; }
        public string IconName { get; set; }
}

My ViewModel:

public class FilterViewModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    public Command MyCommand { get; protected set; }
    private ObservableCollection<TabbedPageIconModel> _myItemsSource;
    public ObservableCollection<TabbedPageIconModel> MyItemsSource
    {
        get
        {
            return _myItemsSource;
        }
        set
        {
            _myItemsSource = value;
            OnPropertyChanged(nameof(MyItemsSource));
        }
    }

    public FilterViewModel()
    {
        MyItemsSource = new ObservableCollection<TabbedPageIconModel>()
        {
            new TabbedPageIconModel() { MyImageURL = "picsum.photos/201", MyImage = new Image(){Source = "picsum.photos/201" }, IconName="Banana1" },
            new TabbedPageIconModel() { MyImageURL = "picsum.photos/202", MyImage = new Image(){Source = "picsum.photos/202" }, IconName="Banana2" },
            new TabbedPageIconModel() { MyImageURL = "picsum.photos/203", MyImage = new Image(){Source = "picsum.photos/203" }, IconName="Banana3" }
        };

        MyCommand = new Command(() => { Debug.WriteLine("Position selected."); });
    }

    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

My View:

<ContentPage.BindingContext>
    <ViewModels:FilterViewModel/>
</ContentPage.BindingContext>

<control:CarouselViewControl 
    ItemsSource="{Binding MyItemsSource}" ShowArrows="True" ShowIndicators="True" Orientation="Horizontal">
    <control:CarouselViewControl.ItemTemplate>
        <DataTemplate>
            <ContentPage>
                <StackLayout>
                    <Image Source="{Binding MyImageURL}"/>
                </StackLayout>
            </ContentPage>
        </DataTemplate>
    </control:CarouselViewControl.ItemTemplate>
</control:CarouselViewControl>


SignalR events not received when iOS app is in the background

$
0
0

Hi
We have a Xamarin Forms app which registers to our SignalR server to receive messages. When the app is in the foreground, everything works fines. However when the app goes into the background on iOS, no event messages are received. We also have turned on background fetch for other work but that did not help. Does anybody know if there is a way to receive SignalR message even while the iOS app is in the background?

Enabling SSL for FTPWebRequest throwing "the authentication or decryption has failed" exception

$
0
0

Hi

I'm Stuck in the connecting through FTP.

I want to securely connect through FTPWebRequest to a FTP server by using TLS 1.1/TLS 1.2, If we set request.EnableSsl = false; we can connect to the FTP server. But when we set request.EnableSsl to true it is throwing "the authentication or decryption has failed" exception.

you can find the source code its only simple app.
https://t.co/yjHqElCeMD?ssr=true
Can you please give me the solution to this...?

I stucked in this from last friday.

Unhandled Exception: Xamarin.Forms.Xaml.XamlParseException:

$
0
0

Hi Everyone,

New to Xamarin. Sorry for that first of all. I keep getting "Unhandled Exception: Xamarin.Forms.Xaml.XamlParseException: occurred". All I did was rename ContentPage to MasterDetailPage in both the XAML and cs for the MainPage.

Thank You,

My need is to upload an image to the ftp server(ftprequest) using Xamarin.forms(Shared Project),I ch

$
0
0

My need is to upload an image to the ftp server(ftprequest) using Xamarin.forms(Shared Project),I checked a lot but i don't get a Proper Way for Uploading,
**SOLUTION PLEASE*

Is there any QR code scanner plugin for android, iOS, windows RT and windows phone?

$
0
0

We require a plugin which should run on android, iOS, windows RT and windows phone device.
Any plugin or help is appreciated.

Nested ListView in Xamarin.Forms (ListView inside another ListView)

$
0
0

I have created a nested ListView in Xamarin.
But unfortunately, the binding works only with the Parent ListView and NOT with the Child List - sub ListView.

I tried to verify if there is any error with my Binding, and my binding works well with the sub List, if i make it as parent.
Any help on this binding, or approach for nested ListView bindings in Xamarin with samples would be much helpful.

how to fetch contacts from phone in xamarin forms ios?

$
0
0

i am fetching contacts from phone by dependency implementation in android by....giving like this....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using MyApps.SemiWallet.Interfaces;
using Xamarin.Forms;
using MyApps.SemiWallet.Droid.DependencyImplementations;
using System.Threading.Tasks;
using MyApps.SemiWallet.Models;
using Android.Provider;

[assembly:Dependency(typeof(ContactHelper))]
namespace MyApps.SemiWallet.Droid.DependencyImplementations
{
class ContactHelper:IContacts
{
public async Task<List> GetDeviceContactsAsync()
{
ContactLists selectedContact = new ContactLists();
List contactList = new List();
var uri = ContactsContract.CommonDataKinds.Phone.ContentUri;
string[] projection = {
ContactsContract.Contacts.InterfaceConsts.Id,
ContactsContract.Contacts.InterfaceConsts.DisplayName,
ContactsContract.CommonDataKinds.Phone.Number
};
var cursor = Xamarin.Forms.Forms.Context.ContentResolver.Query(uri, projection, null, null, null);
if (cursor.MoveToFirst())
{
do
{
contactList.Add(new ContactLists()
{
DisplayName = cursor.GetString(cursor.GetColumnIndex(projection[1])),
ContactNumber = cursor.GetString(cursor.GetColumnIndex(projection[2]))
});
} while (cursor.MoveToNext());
}
return contactList;
}
private object ManagedQuery(Android.Net.Uri uri, string[] projection, object p1, object p2, object p3)
{
throw new NotImplementedException();
}

}

}

then how to implement for ios????


error : Can't resolve the reference 'System.Void Xamarin.Forms.BindingBase::Unapply()'

$
0
0

When I am trying to deploy the application on iPhone and iPhoneSimulator I am getting this strange error.

error : Can't resolve the reference 'System.Void Xamarin.Forms.BindingBase::Unapply()', referenced from the method 'System.Void Xamarin.Forms.Pages.DataSourceBinding::Unapply()' in 'Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.

Any idea how to fix it?

How do I get the total page count?

$
0
0

Hi,
I am looking to get the total page count of the pages used in the setup part of an app. Unfortunately I cannot use anything but Modal-pages to keep the user on one page before being able to proceed to the next one because the setup needs to be done correctly.

I have looked around and I cannot seem to find a way to find the total amount of pages that this setup will go through. Is there a way to do this?

Thank you very much in advance for helping out.

Xamarin Android Archiving Failed (The "LinkAssemblies" task failed unexpectedly.)

$
0
0

I have been getting the following error when I try to build a release version with Linking properties set to "Sdk Assemblies Only" :

Severity Code Description Project File Line Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'System.Void ObjCRuntime.Runtime::set_UseAutoreleasePoolInThreadPool(System.Boolean)' in assembly: 'Xamarin.iOS.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void System.Threading._ThreadPoolWaitCallback::SetDispatcher(System.Func2<System.Func1<System.Boolean>,System.Boolean>)
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessEntireQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() IvyApps.Android C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1748

Can anyone shed some light on this?

Layout breaks when changing font size

$
0
0

Using Xamarin PCL and creating pages with most of the layout managed within an a grid where I store my views. The problem occurs when changing the Font size within the system for example Android(to huge) the layout breaks. How to keep a consistent layout for different font sizes?

macOS/WPF Desktop App using Xamarin.Forms

$
0
0

Hi everyone,

At one of our Customers we have a WinForms Application that in the near Future should be ported to something that also runs under macOS. So after checking out different possibilities to make that happen (WebApplication,ElectronJS,WinForms running in WineContainer) i saw Xamarin.Forms has now both WPF and macOS Backends in Preview. Im interested in trying that out as i think we could reuse quite a bit of code from the WinForms Solution.

My Question is how stable are the WPF/macOS Backends by now (does anyone have experience?) and are they going to be actively developed in the near future to be incorporated into a stable Release. Or is it more like an Experiment,seeing that Xamarin.Forms is still mainly advertised as a Mobile/UWP XPlatform Solution?

Thanks for any Feedback,
Alex

Controlling transition speed of a carousel page

$
0
0

I have automated the scrolling of a carousel page by increasing an index variable on each page load and setting the carousel CurrentPage = Children[index].

This works well, but I find that when the new page slides in it does so too fast as it's not controlled with a swipe gesture, is there anyway to control this?

I won't post the code, as it's basically a carousel page with 12 child pages, after a set amount of time I run this line of code

CurrentPage = Children[index];

setting the next child page, until it gets to the end where it resets to the beginning.
As I say I have it working well but wonder of there is any way to control the speed of how each page appears to slide in, I can't find much online about this.
Thanks

Draw a line between two controls

$
0
0

Hello!

I would like to create a simple structure of organizational chart, and so far, i'm dynamically adding buttons to StackLayout. When i click a button, i create another one and put him in StackPanel.

Now i would like to create a line, connecting clicked button and newly created one.

I would appreciate any help!


Do something when async task finishes

$
0
0

Hi,

In my App initialization I have asynchronous call:

string output = "";
Task.Run(async () => { output = await ds.ReloadUsers(); });

After it finishes, output is equal to JSON serialized data which is as follows:

    [
        {
            "UserId": 4,
            "Name": "Krzysztof",
            "Surname": "Jeżyna",
            "Password": "jdepass123",
            "isMechanic": true,
            "TenantId": 1,
            "TenantName": "JDE_PL",
            "CreatedOn": "2018-04-18T07:00:00",
            "CreatedBy": 1,
            "CreatedByName": "Robert Roszak",
            "LastLoggedOn": null
        },
        {
            "UserId": 6,
            "Name": "Tomasz",
            "Surname": "Gorkowski",
            "Password": "jdepass123",
            "isMechanic": true,
            "TenantId": 1,
            "TenantName": "JDE_PL",
            "CreatedOn": "2018-04-20T11:06:47.413",
            "CreatedBy": 1,
            "CreatedByName": "Robert Roszak",
            "LastLoggedOn": null
        }
    ]

Now I must deserialize output to List, like:

List<User> Users = new List<User>();
Users = JsonConvert.DeserializeObject<List<User>>(output);

However, I don't know where to put it so it's triggered only when asynchronously called Task.Run finishes. I thought that maybe I could put it within the call, but it doesn't work:

Task.Run(async () => { output = await ds.ReloadUsers();
                Users = JsonConvert.DeserializeObject<List<User>>(output);
            });

So maybe there's some event I could use to deserialize output only when Task.Run finishes? How do I go about it?

ObservableCollection with condition (where)

$
0
0

I have a project with a ExpandableListView create on Xamarin.Forms
On an item if i click i load a new activity to show all informations of this item and i can click on an image to expand this item. When i don't have condition on the list no problem it's working but if i put a where condition like that
c# FournisseursListView.ItemsSource = vm.Fournisseurs.Where(x => x.BoolActifFournisseur == true).ToList();
it doesn't work.

c# FournisseursListView.ItemsSource = vm.Fournisseurs; this code without condition work

When i click on this image, it's set to isVisible the property of the item and replace this. (remove and add row)

  public void ShowOrHideDetailFournisseur(Fournisseur Fournisseur)
    {
        if (_oldFournisseur == Fournisseur)
        {

            Fournisseur.IsVisible = !Fournisseur.IsVisible;
            UpdateFournisseurs(Fournisseur);

        }
        else
        {
            if (_oldFournisseur != null)
            {
                // hide previous selected item
                _oldFournisseur.IsVisible = false;
                UpdateFournisseurs(_oldFournisseur);
            }
            // show selected item
            Fournisseur.IsVisible = true;
            UpdateFournisseurs(Fournisseur);
        }

        _oldFournisseur = Fournisseur;
    }



    private void UpdateFournisseurs(Fournisseur Fournisseur)
    {

        var index = Fournisseurs.IndexOf(Fournisseur);
        Fournisseurs.Remove(Fournisseur);
        Fournisseurs.Insert(index, Fournisseur);


    } 

I can share you my github if you want to see all of the code.
Thanks in advance.

A quick question about Camera Preview

$
0
0

I have success show a Camera Preview (I use CustomRenderer a View) and draw a Rectangle at the center of Camera Preview (I use SkiaSharp to draw directly in xaml.cs file).
Now I only want to get Image (take a shot or video) inside that Rectangle.
How to do that!
Thank you

System.ArgumentException crash in custom UWP FrameRenderer

$
0
0

Hi,

I'm using a custom FrameRenderer in my UWP project to style frames (corner radius and color). When I scroll a bit back and forth, the app crashes with a System.ArgumentException: Value does not fall within the expected range. It's the call to base.OnElementChanged(e); that causes it.

I can of course put that in a try/catch, but then some items in my list will disappear. They return on orientation change of the device, but not after a normal refresh of the FlowListView I'm using.

Any ideas? I'm on Xamarin Forms 2.5.1.444934.

Here's the custom FrameRenderer:

class ExtendedFrameRenderer : FrameRenderer
{
    protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
    {
        base.OnElementChanged(e);

        if (Control != null)
        {
            var frame = e.NewElement;
            double cornerRadius = frame.CornerRadius;

            Windows.UI.Color frameBG = Windows.UI.Color.FromArgb(
                (byte)(frame.BackgroundColor.A * 255),
                (byte)(frame.BackgroundColor.R * 255),
                (byte)(frame.BackgroundColor.G * 255),
                (byte)(frame.BackgroundColor.B * 255));

            Control.CornerRadius = new Windows.UI.Xaml.CornerRadius(cornerRadius);
            Control.Background = new SolidColorBrush(frameBG);
            frame.BackgroundColor = Xamarin.Forms.Color.Transparent;
        }
    }
}

Full error stack:

System.ArgumentException
  HResult=0x80070057
  Message=Value does not fall within the expected range.
  Source=Windows
  StackTrace:
   at Windows.UI.Xaml.Controls.Border.put_Child(UIElement value)
   at Xamarin.Forms.Platform.UWP.FrameRenderer.PackChild()
   at Xamarin.Forms.Platform.UWP.FrameRenderer.OnElementChanged(ElementChangedEventArgs`1 e)
   at MyApp.UWP.Helpers.ExtendedFrameRenderer.OnElementChanged(ElementChangedEventArgs`1 e) in C:\Users\me\Source\Workspaces\MySol\MyApp\MyApp.UWP\Helpers\ExtendedFrameRenderer.cs:line 26
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
   at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
   at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
   at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
   at Xamarin.Forms.Platform.UWP.ViewToRendererConverter.WrapperControl..ctor(View view)
   at Xamarin.Forms.Platform.UWP.ViewToRendererConverter.Convert(Object value, Type targetType, Object parameter, String language)

Phone Number Verification when sign up into the app.

$
0
0

In my app there is requirement for phone number verification at the time of sign up. I want to get verification code at given mobile number at the time of sign up.
How to achieve this functionality in Xamarin.Forms App.

Please help. I am new to xamarin and xamarin.forms development.

Thanks in Advance.

Viewing all 89864 articles
Browse latest View live


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