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

System.ArgumentException: Handle must be valid

$
0
0

Hello,

08-20 12:31:42.660 E/mono    (24148): Unhandled Exception:
08-20 12:31:42.660 E/mono    (24148): System.ArgumentException: Handle must be valid.
08-20 12:31:42.660 E/mono    (24148): Parameter name: instance
08-20 12:31:42.660 E/mono    (24148):   at Java.Interop.JniEnvironment+InstanceMethods.CallBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) [0x00009] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
08-20 12:31:42.660 E/mono    (24148):   at Android.Runtime.JNIEnv.CallBooleanMethod (System.IntPtr jobject, System.IntPtr jmethod) [0x0000e] in <227a96d68a0440cea172be41b1306654>:0 
08-20 12:31:42.660 E/mono    (24148):   at Java.Util.IIteratorInvoker.get_HasNext () [0x00033] in <227a96d68a0440cea172be41b1306654>:0 
08-20 12:31:42.660 E/mono    (24148):   at System.Linq.Extensions+<ToEnumerator_Dispose>d__5`1[T].MoveNext () [0x00063] in <227a96d68a0440cea172be41b1306654>:0 
08-20 12:31:42.660 E/mono    (24148):   at System.Linq.Enumerable+SelectIListIterator`2[TSource,TResult].MoveNext () [0x00029] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Linq/src/System/Linq/Select.cs:487 
08-20 12:31:42.660 E/mono    (24148):   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_1 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1037 
08-20 12:31:42.660 E/mono    (24148):   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x0000d] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1370 
08-20 12:31:42.660 E/mono    (24148):   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:968 
08-20 12:31:42.660 E/mono    (24148):   at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:910 
08-20 12:31:42.660 E/mono    (24148):   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1341 
08-20 12:31:42.660 E/mono    (24148):   at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:899 
08-20 12:31:42.660 E/mono    (24148):   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1261 
08-20 12:31:42.662 E/mono-rt (24148): [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Handle must be valid.
08-20 12:31:42.662 E/mono-rt (24148): Parameter name: instance
08-20 12:31:42.662 E/mono-rt (24148):   at Java.Interop.JniEnvironment+InstanceMethods.CallBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) [0x00009] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
08-20 12:31:42.662 E/mono-rt (24148):   at Android.Runtime.JNIEnv.CallBooleanMethod (System.IntPtr jobject, System.IntPtr jmethod) [0x0000e] in <227a96d68a0440cea172be41b1306654>:0 
08-20 12:31:42.662 E/mono-rt (24148):   at Java.Util.IIteratorInvoker.get_HasNext () [0x00033] in <227a96d68a0440cea172be41b1306654>:0 
08-20 12:31:42.662 E/mono-rt (24148):   at System.Linq.Extensions+<ToEnumerator_Dispose>d__5`1[T].MoveNext () [0x00063] in <227a96d68a0440cea172be41b1306654>:0 
08-20 12:31:42.662 E/mono-rt (24148):   at System.Linq.Enumerable+SelectIListIterator`2[TSource,TResult].MoveNext () [0x00029] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Linq/src/System/Linq/Select.cs:487 
08-20 12:31:42.662 E/mono-rt (24148):   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_1 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1037 
08-20 12:31:42.662 E/mono-rt (24148):   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context (System.Object state) [0x0000d] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1370 
08-20 12:31:42.662 E/mono-rt (24148):   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:968 
08-20 12:31:42.662 E/mono-rt (24148):   at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:910 
08-20 12:31:42.662 E/mono-rt (24148):   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00021] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1341 
08-20 12:31:42.662 E/mono-rt (24148):   at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:899 
08-20 12:31:42.662 E/mono-rt (24148):   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1261 

Method:

     if (querySnapshot != null)
                {
                    lastVisibleDocument = querySnapshot.Documents.LastOrDefault();
 **                   foreach (var documentChange in querySnapshot.DocumentChanges) this line gives an error ** 
                    {
                        Message message;
                        switch (documentChange.Type)
                        {
                            case DocumentChangeType.Added:
                                message = documentChange.Document.ToObject<Message>();
                        __**        var user = await Search(message.FromId); has to do with await**__
                                message.FromName = user.Name;
                                List.Add(message);
                                break;
                            case DocumentChangeType.Modified:
                                break;
                            case DocumentChangeType.Removed:
                                break;
                        }
                    }
                }

this piece of code is from a delegate, how can I fix it?


System.ArgumentException: Handle must be valid. Parameter name: instance while navigating backwards

$
0
0

I have a main page which is a MasterDetailPage, Detail page of which is set as:
Detail = new NavigationPage(new ContentPage())

Then I navigate to ContentPage -> ListPage
On ListPage I have an image which has a tapGestureRecognizer. drillTapped command is executed every time user taps the Image. Inside this command, I am navigating to another page.

                private void OnDrill(object obj)
                    {
                            Navigation.PushAsync(new HomePage((obj as chartObject)));
                }

So my Navigation now is:
ContentPage -> ListPage -> HomePage
Everything works fine as expected. and chart can be seen on HomePage.

When I press Back Button on Navigation Bar, I Navigate back to ListPage. NOW if I press back, I should Navigate Back to ContentPage But I am getting following Exception.

UNHANDLED EXCEPTION: System.ArgumentException: Handle must be valid. Parameter name: instance at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method) [0x00017] in /Users/builder/data/lanes/4009/3a62f1ea/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11650 at Android.Runtime.JNIEnv.CallNonvirtualObjectMethod (System.IntPtr jobject, System.IntPtr jclass, System.IntPtr jmethod) [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/monodroid/src/Mono.Android/JNIEnv.g.cs:276 at Com.Syncfusion.Charts.SfChart.get_PrimaryAxis () [0x00075] in <7214c1e575e942b98a604e773eb60d00>:0 at Syncfusion.SfChart.XForms.Droid.Disposer.DisposeNativeContents (Syncfusion.SfChart.XForms.SfChart sfChart) [0x0001c] in <34661f52d3f246459037fafce7510c25>:0 at Syncfusion.SfChart.XForms.Droid.Disposer.Dispose (Syncfusion.SfChart.XForms.SfChart sfChart) [0x00000] in <34661f52d3f246459037fafce7510c25>:0 at Syncfusion.SfChart.XForms.Droid.SfChartRenderer.Dispose (System.Boolean disposing) [0x00015] in <34661f52d3f246459037fafce7510c25>:0 at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203 at Xamarin.Forms.Platform.Android.VisualElementRenderer ``1[TElement].Dispose (System.Boolean disposing) [0x000b3] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:262 at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203 at Xamarin.Forms.Platform.Android.VisualElementRenderer ``1[TElement].Dispose (System.Boolean disposing) [0x000b3] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:262 at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203 at Xamarin.Forms.Platform.Android.VisualElementRenderer ``1[TElement].Dispose (System.Boolean disposing) [0x000b3] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:262 at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203 at Xamarin.Forms.Platform.Android.ScrollViewContainer.Dispose (System.Boolean disposing) [0x00013] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ScrollViewContainer.cs:49 at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203 at Xamarin.Forms.Platform.Android.ScrollViewRenderer.Dispose (System.Boolean disposing) [0x00029] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ScrollViewRenderer.cs:156 at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203 at Xamarin.Forms.Platform.Android.VisualElementRenderer ``1[TElement].Dispose (System.Boolean disposing) [0x000b3] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:262 at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean disposing) [0x00011] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\PageRenderer.cs:20 at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203 at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView () [0x0003f] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:90 at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <7a2a36256f1648ecbd0c15a75bc5a349>:0 at (wrapper dynamic-method) System.Object:ad8e1634-b787-479f-a839-e167f50bda3f (intptr,intptr)

However if i do following, I don't get any exception in navigating all the way to rootPage and no exception is seen:
private void OnDrill(object obj)
{
Navigation.PushAsync(new HomePage());
}
As i can guess by reading Dispose() , This is appearing while destroying some object but I am not sure which..
Can anybody help me to understand the problem and possibly suggest some solutions or workaround?

Is any code inside Device.BeginInvokeOnMainThread(() =>{ /*this code*/}) executed on the main thread

$
0
0

I got this exception:
System.Exception: 'Sending events is only supported from the main thread. You can omit this exception by subscribing to Urho.Application.UnhandledException event and set Handled property to True.

in this code:

        private async void CreateScene()
        {
            scene = new Scene();
            octree = scene.CreateComponent<Octree>(); //Exception on this line

So I called CreateScene this way:

            Device.BeginInvokeOnMainThread(() =>
            {
                CreateScene();
            });

But I still get the same exception. The line that rises the exception should be on the main thread should not it?

Custom request header not sent in Xamarin.Forms Webview

$
0
0

Did anyone ever try to "inject" an authentication header into a forms or native WebView? Is there a good solution for that?

We need to make a GET request to a webpage from within the forms app and we have to send an access token in an Authentication header. I already implemented custom WebViewRenderers (for iOS and Android) in which I override the OnElementChanged method, the code runs without any errors through but the header is not sent with the request. It does not work in either Android or iOS.

Here is my current implementation of the WebViewRenderers:

namespace MyNamespace.Droid.Renderers
{
public class HybridWebViewRenderer : WebViewRenderer
{
public HybridWebViewRenderer(Context context) : base(context){}

    protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
    {
        base.OnElementChanged(e);
        var webView = e.NewElement as HybridWebView;
        var token = "dummytoken";
        IDictionary<string, string> headers = new Dictionary<string, string>
        {
            {"Authorization", "Bearer " + token }
        };
        string url = ((UrlWebViewSource)webView.Source).Url;

        Control.LoadUrl(url, headers);
    }

[assembly: ExportRenderer(typeof(HybridWebView), typeof(HybridWebViewRenderer))]
namespace MyNamespace.iOS.Renderers
{
public class HybridWebViewRenderer : WkWebViewRenderer
{
public static void Initialize()
{ }

    protected override void OnElementChanged(VisualElementChangedEventArgs e)
    {
        base.OnElementChanged(e);
        var webView = e.NewElement as HybridWebView;
        var url = ((UrlWebViewSource)webView.Source).Url;
        var newRequest = new NSMutableUrlRequest();
        var token = "dummytoken";
        NSMutableDictionary dic = new NSMutableDictionary();
        dic.Add(new NSString("Authorization"), new NSString("Bearer " + token));
        newRequest.Headers = dic;
        newRequest.Url = new NSUrl(url);

        LoadRequest(newRequest);
    }

For Android I already tried the WebViewClient approach also, without success. (from here https://forums.xamarin.com/discussion/87944/custom-header-in-webview)

Any ideas? Thank you.

Open mobile camera in webview

$
0
0

I'm building an application where i load website in a webview.

On website i open device camera ( take pics etc ) and its working perfectly fine on all browsers but when i load same application in xamarin.forms web view, mobile camera doesn't show up. Any idea what could be the reason ?

Regards
TA

Submission of UWP app to Windows Store - error code 1201

$
0
0

Hey guys, first time posting on the forum!

It's been 3 weeks that I am trying to upload my app to the Windows Store with no luck.

My project runs perfectly on "Release Mode" and even if I sideload it.

I am able to submit the .appxbundle (I'm building for ARM, x86 and x64) but after about 5 minutes it's in the certification, I get this error:

"_This submission failed with error code(s) 1201 . More info about the error(s) can be found here."

Of course, if you go to the link there's nothing related to this issue. So I emailed Microsoft Submission team and after multiples emails, they have said:

After reviewing the information with our specialized team, we found per your app manifest, the Mobile phone package/schema was not removed
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest

You must remove coding related to Windows Mobile in Manifest or create a new package with Mobile phone package and resubmit.

I tried removing from the lines from the manifest but I get lots of other .NET errors, so I'm assuming that's not the way to go. Plus, all Xamarin.Forms examples on Github have this. I thought it was a very weird advice.

I asked how I could go about doing this and that was the answer:

Please create a new package without Mobile phone package and resubmit. as we no longer support mobile apps/devices. Your error means you can not remove the mobile phone package, instead you must create a new package.

I must be missing something really obvious but I'm not targeting Windows Phones, but Windows DESKTOP. So on the package submission to Windows store, everything is unchecked except for "Windows Desktop".

Do you guys think this mobile thing is related? Have you guys experienced something similar? I'm frustrated!

Specifics
Xamarin.Forms 4.8.0.1269
.NET Standard 2.0.3
.NETCore.UniversalWindowsPlatform 6.2.10

EDIT

My app has successfully passed on the Local Windows Ceritfication Tool Kit

Sudden error: "expected color but got (raw string)" in Android

$
0
0

Hi!

I've updated Visual Studio to version 16.7.1 and ever since I did that I get an error which was not there before:

This only happens with Android. Line 4 in styles.xml is this:

I read something about updating from packges.config to PackagesReferences might help, but I'm unable to find the migration option in my solution (right-click on References does not show the migrate option).

Does someone wthat is wrong here and how to solve this?

Best regards

Black screen on iOS 13 HELP

$
0
0

When i run this app in iOS 13 I get a black screen immediately after the launch screen.
With iOS 12.2 annd earlier everything works.

This is my AppDelegate.cs:

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            App.StatusBarHeight = (int)UIApplication.SharedApplication.StatusBarFrame.Height;

            FFImageLoading.Forms.Platform.CachedImageRenderer.Init();

            // Syncfusion components
            Syncfusion.SfNumericUpDown.XForms.iOS.SfNumericUpDownRenderer.Init();
            Syncfusion.XForms.iOS.Border.SfBorderRenderer.Init();
            Syncfusion.XForms.iOS.Buttons.SfButtonRenderer.Init();
            Syncfusion.SfChart.XForms.iOS.Renderers.SfChartRenderer.Init();

            LoadApplication(new App(new iOSInitializer()));

            return base.FinishedLaunching(app, options);
        }

Then my App.xaml.cs looks like this:

    protected override async void OnInitialized()
            {
                InitializeComponent();

                await NavigationService.NavigateAsync("Navigation/DebugPage");
            }

For now i am just redirecting to a blank page with a label in it, so there are no controls or anything.
It's just all black (no status bar either).

Thanks for any help!


Picker behaviour on Android

$
0
0

Hi,

I'm not sure if this is by design, or a bug - but in Android, a Picker control seems to allow the user to type in any old text, i.e. not limit the selection to just the ItemsSource collection.

Click on a Picker.
It's list of items will be displayed.
Click Cancel to dismiss the list.
Notice the picker still has focus.
Type on the physical keyboard of the device.
The text typed in will appear in the Picker! The SelectedIndex won't fire etc so the Picker actually doesn't have any selected item, but that text appearing will stay there even if you move focus to another control - obviously giving the appearance that something is selected!

How to make Top Tab Bar to Top Bar ?

How make and animate a "pizza like" shape ?

$
0
0

Hello,

I am trying to make a circle progressbar like this :

And also animate it from 0 to 360°. I cannot find anything to make this. :neutral:

Can someone give me some tips ? :smiley:

Thanks !

Get current value as string from Binding

$
0
0

I'm trying to learn to work with local databases and more with Binding, so I my question might be strange.

I'm using a tutorial from Microsoft for understanding how to work with SQL Databases:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/data/databases

The app in the tutorial is full of binding as you can see.
When I want to edit a new item in the list, the code does the following to go to the other page:

Now I want to show the name of the item in a displayalert on the next page, so I need to get the binding result of 'Name' as a string in the C# code.

How can I do this?

My App Is not showing any GUI when deployed in physical Device.

$
0
0

I have the following issue:
I tried to use MagicGradients pluggin for showing beautiful gradients in background, I had issues because sometimes it did not showed me the gui, but i managed to make it work. Then I closed visual studio and now it asked me to recover the xaml files which I apply the magic gradient for background, so I pressed Recover. Visual studio opened my project, tried to deploy it in my physical device and it does not show anything, I uninstalled magicgradients pluggin and the same. All the app shows me is a blank page with nothing. Looks like it is loading the app forever.

I have this code in my app.xaml.cs:

using DeltaApp.Controls;
using DeltaApp.View;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace DeltaApp
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();

            MainPage = new CustomNavigationPage(new HomePage());
        }
    }
}

My App.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             mc:Ignorable="d"
             x:Class="DeltaApp.App">
    <Application.Resources>

    </Application.Resources>
</Application>

My HomePage.xaml:

<?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:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="DeltaApp.View.HomePage">
    <StackLayout Padding="20,50">
        <Label Text="Traceability App"
               HorizontalOptions="Center"
               Margin="0,0,0,150"/>
        <Button x:Name="BtnNavigateP1"
                Text="Plantilla 1"
                BackgroundColor="Orange"
                CornerRadius="15"
                Margin="0,0,0,20"
                VerticalOptions="Center"
                Clicked="BtnNavigateP1_Clicked"
                />
        <Button x:Name="BtnNavigateP2"
                Text="Plantilla 2"
                BackgroundColor="Orange"
                CornerRadius="15"
                VerticalOptions="Center"
                Clicked="BtnNavigateP2_Clicked"/>

    </StackLayout>
</ContentPage>

And it does not show me the controls in the HomePage.xaml.

I Tried:

  • delete bin obj folders for each project (shared project, .droid, .ios)
  • Clean solution and rebuild.
  • delete bin obj folders for each project (shared project, .droid, .ios), Restart Visual Studio, rebuild and deploy.

I am using:

  • Microsoft Visual Studio Community 2019 - Versión 16.6.5
  • Xamarin - 16.6.000.1064
  • Android Target Plattform Android 9.0 Pie
  • Android minimum Version Android 5.0 Lollipop

This is the view of my app:

Major Error while building Xamarin Forms Project

$
0
0

We have built a small scale application in Xamarin Studio for Mac 2019, that utilizes checkboxes. We keep getting the same error : No Property, Bindable Property, or event found for "Children", or mismatching type between value and property There is no class or function that we have created named "Children". Please advise on what we are doing wrong. Attached a screenshot of the error

Video player in Xamarin forms too slow to start buffering/playing

$
0
0

I was experimenting with some nuget package video players in Forms, and I tried

  1. the new experimental MediaElement video player
  2. the Nuget package Xam.Forms.VideoPlayer which seems to be based on the sample video player at https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/customrenderers-videoplayerdemos/
  3. Nuget package @ https://github.com/adamfisher/Xamarin.Forms.VideoPlayer that is no longer maintained.

However, they all seemed to take a long time to start buffering, and then a long time before they finally started playing.

I compared the three and the fastest to start playing seemed to be Xam.Forms.VideoPlayer (marginally faster than other two).
Finally, I timed just this one, loading a video from Amazon s3. It took about 10 seconds before the video element sized itself to the correct aspect ratio and started buffering. Then another 10 seconds before it started actually playing, for a total of 20 seconds.

By way of comparison, when I opened the s3 link directly in my Edge web browser, it took only 10 seconds to start playing.

I was wondering if others are also experiencing the same performance? Is this normal?

Thanks for reading/commenting.

By the way, this is my code:

                    <video:VideoPlayer
                        x:Name="videoPlayer"
                        AutoPlay="False"
                        BackgroundColor="White"
                        HeightRequest="300"
                        IsBuffering="{Binding IsVideoBuffering, Mode=OneWayToSource}"
                        IsVisible="{Binding IsVideoVisible}"
                        Source="{Binding VideoSource}" />

Slow download speeds on Android using HttpClient

$
0
0

Hi,

I'm fairly new to Xamarin and have built an app that allows users to download a large video file (~800MB). I'm finding that the download speed on Android (emulator and real device) is very slow (< 1MB/s), especially compared to the speed I'm getting on the iOS simulator. I'm building with AndroidClientHandler and Native TLS 1.2+. Here is my download code:

public async void DownloadVideo(FilmVersion version)
{
    using (HttpClient client = new HttpClient())
                {
                    try
                    {
                        client.Timeout = System.Threading.Timeout.InfiniteTimeSpan;
                        client.DefaultRequestHeaders.Authorization =
                            new AuthenticationHeaderValue("Bearer", Secrets.Token);
                        var queryString = "";
                        if (version == FilmVersion.NonSubtitle)
                        {
                            queryString = "version=standard";
                        }
                        else if (version == FilmVersion.Subtitle)
                        {
                            queryString = "version=subtitles";
                        }
                        HttpResponseMessage response = await client.GetAsync("https://filmURL?" + queryString, HttpCompletionOption.ResponseHeadersRead);
                        TotalRead = 0;
                        totalSize = (float)response.Content.Headers.ContentLength;
                        var stream = await response.Content.ReadAsStreamAsync();
                        int bufferSize = 4095;
                        var path = Path.Combine(FileSystem.CacheDirectory, "plain-video.mp4");

                        // Downlaod the video.
                        using (fs = File.OpenWrite(path))
                        {
                            var buffer = new byte[bufferSize];
                            var isMoreDataToRead = true;
                            do
                            {
                                var read = await stream.ReadAsync(buffer, 0, buffer.Length);

                                if (read == 0)
                                {
                                    isMoreDataToRead = false;
                                }
                                else
                                {
                                    // Write data on disk.
                                    await fs.WriteAsync(buffer, 0, read);

                                    TotalRead += read;
                                }
                            } while (isMoreDataToRead);
                            _ticket.FilmSize = fs.Length;
                        }
            }
            catch ...

TotalRead and totalSize are binding to the UI to provide progress feedback.

Any thoughts or suggestions would be greatly appreciated!

Get Image size in Pixel

$
0
0

Hi,

How can I get the displayed image size in pixels?

What I mean by displayed size is not the real size of the image but the on screen size so if the image is stretched, centered, landscape, etc then I need to get that displayed size in pixels

Thanks,
Jassim

Show MenuItem with Tap

$
0
0

I'm developing cross platform app with Xamarin Forms. I'm wondering if there's an easy way to show MenuItem in a listView with a single tap on a cell. Now of course, my MenuItem is displayed when user swipes to left, but I would like to show menu when user just tap on a cell. How can I do that? I tried to translate ViewCell but, even if translation works, nothing appears. Have I to make something custom? Maybe is it possible to "force" a left swipe when user taps on a cell? I tried to find some reference on web and documentation but found nothing

very easy code for MenuItem implementation

<ViewCell.ContextActions>
        <MenuItem Text="Delete" Clicked="DeleteElement" x:Name="menuItem"/>
</ViewCell.ContextActions>

code for ViewCell translation:

await viewCell.View.TranslateTo(-100, 0, 250, Easing.SinIn);

Thanks guys

Shapes are Awesome!

$
0
0

I love the new Shapes... here's a Chevron shape in the Expander header, toggles between pointing up & down.

<Expander IsExpanded="False">
    <Expander.Header>
        <StackLayout 
            BackgroundColor="{DynamicResource CardLabelColor}"
            HorizontalOptions="FillAndExpand"
            Orientation="Horizontal"
            >
            <Label
                Text="Filter"
                TextColor="{DynamicResource CardLabelContrastColor}"
                Margin="5,10"
                FontSize="{StaticResource CardHeaderFontSize}"
                VerticalTextAlignment="Center"
                VerticalOptions="Center"
                />
            <AbsoluteLayout
                VerticalOptions="Center"
                HorizontalOptions="EndAndExpand"
                Margin="8"
                WidthRequest="32"
                >
                <Ellipse
                    AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                    AbsoluteLayout.LayoutFlags="All" 
                    HorizontalOptions="Fill"
                    VerticalOptions="Fill"
                    Fill="{AppThemeBinding Dark=#44000000, Light=#44FFFFFF}"
                    />
                <Path
                    AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                    AbsoluteLayout.LayoutFlags="All" 
                    HorizontalOptions="Center"
                    VerticalOptions="Center"
                    Data="M 0,8 L 12,16 24,8 Z"
                    Fill="White"
                    Stroke="White"
                    StrokeThickness="2"
                    Aspect="Uniform"
                    Margin="8"
                    >
                    <Path.Triggers>
                        <DataTrigger 
                            TargetType="Path"
                            Binding="{Binding Source={RelativeSource AncestorType={x:Type Expander}}, Path=IsExpanded}"
                            Value="True">
                            <Setter
                                Property="Data"
                                Value="M 0,16 L 12,8 24,16 Z"
                                />
                        </DataTrigger>
                    </Path.Triggers>
                </Path>
            </AbsoluteLayout>
        </StackLayout>
    </Expander.Header>
    <Frame StyleClass="CardExpanderFrame">
        <StackLayout Orientation="Vertical">
            ... setting form...
        </StackLayout>
    </Frame>
</Expander>

Expander and Shapes

$
0
0

I love the new Shapes... here's a Chevron shape in the Expander header, toggles between pointing up & down.

<Expander IsExpanded="False">
    <Expander.Header>
        <StackLayout 
            BackgroundColor="{DynamicResource CardLabelColor}"
            HorizontalOptions="FillAndExpand"
            Orientation="Horizontal"
            >
            <Label
                Text="Filter"
                TextColor="{DynamicResource CardLabelContrastColor}"
                Margin="5,10"
                FontSize="{StaticResource CardHeaderFontSize}"
                VerticalTextAlignment="Center"
                VerticalOptions="Center"
                />
            <AbsoluteLayout
                VerticalOptions="Center"
                HorizontalOptions="EndAndExpand"
                Margin="8"
                WidthRequest="32"
                >
                <Ellipse
                    AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                    AbsoluteLayout.LayoutFlags="All" 
                    HorizontalOptions="Fill"
                    VerticalOptions="Fill"
                    Fill="{AppThemeBinding Dark=#44000000, Light=#44FFFFFF}"
                    />
                <Path
                    AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
                    AbsoluteLayout.LayoutFlags="All" 
                    HorizontalOptions="Center"
                    VerticalOptions="Center"
                    Data="M 0,8 L 12,16 24,8 Z"
                    Fill="White"
                    Stroke="White"
                    StrokeThickness="2"
                    Aspect="Uniform"
                    Margin="8"
                    >
                    <Path.Triggers>
                        <DataTrigger 
                            TargetType="Path"
                            Binding="{Binding Source={RelativeSource AncestorType={x:Type Expander}}, Path=IsExpanded}"
                            Value="True">
                            <Setter
                                Property="Data"
                                Value="M 0,16 L 12,8 24,16 Z"
                                />
                        </DataTrigger>
                    </Path.Triggers>
                </Path>
            </AbsoluteLayout>
        </StackLayout>
    </Expander.Header>
    <Frame StyleClass="CardExpanderFrame">
        <StackLayout Orientation="Vertical">
            ... setting form...
        </StackLayout>
    </Frame>
</Expander>
Viewing all 79144 articles
Browse latest View live


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