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

Error when changing Entry.IsPassword property (only on UWP/Win 8.1)

$
0
0

I get the following error in the following scenario (please download the attached sample project and follow the guide to reproduce):

Error:

    System.ArgumentException


The parameter is incorrect.

    E_RUNTIME_SETVALUE

   at Windows.UI.Xaml.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Xamarin.Forms.Platform.UWP.EntryRenderer.UpdateIsPassword()
   at Xamarin.Forms.Platform.UWP.EntryRenderer.OnElementChanged(ElementChangedEventArgs`1 e)
   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.VisualElementExtensions.GetOrCreateRenderer(VisualElement self)
   at Xamarin.Forms.Platform.UWP.NavigationPageRenderer.SetPage(Page page, Boolean isAnimated, Boolean isPopping)
   at Xamarin.Forms.Platform.UWP.NavigationPageRenderer.OnPushRequested(Object sender, NavigationRequestedEventArgs e)
   at Xamarin.Forms.NavigationPage.<PushAsyncInner>d__90.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.Forms.NavigationPage.<PushAsync>d__48.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at App1.App.<ListView_ItemTapped>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
   at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()

The error occurs only on UWP/Windows and only if you toggle the "IsPassword" property of an "Entry" view.

Steps to reproduce:

1) Download the attached project and run the UWP project
2) On the main application page click any item of the ListView
3) On the page that opens, click the "Show/Hide" button twice
4) Go back to the previous page
5) Click any item of the ListView again

If you click the "Show/Hide" once, then the error does not appear !!


How to SELECT dynamic type of objects in SQLiteAsyncConnection

$
0
0

I'm trying to build a database where all of it's queries comes from the server.

database = new SQLiteAsyncConnection(dbPath);

The server's queries are divided into two parts[execution & retrieval]

for the execution queries I'm using this line of code

database.ExecuteAsync(serverResponse);

where serverResponse may be a sql CREATE, INSERT or UPDATE statement.

As for the retrieval queries I'm trying to find a way to retrieve dynamic objects from the database and serialize them to send them to the database. I'm trying to make something like this to retrieve the list of objects in database

var ls = await database.QueryAsync<dynamic>(serverResponse);

but this statement returns a List of objects, and I don't know how to use it.

I tried something like this locally

database.ExecuteAsync("CREATE TABLE Persons(PersonID int);");
database.ExecuteAsync("INSERT INTO Persons(PersonID) VALUES (5);");
var ls = await database.QueryAsync<dynamic>("SELECT * FROM Persons");
int x = ls[0].PersonID;

But it gives me this error 'object' does not contain a definition for 'PersonID'; which says that I need to cast the object to a Person class to be able to use it.

How can I serialize the result of any query without the need to cast it.

Retrieving logs from a failed iOS deploy

$
0
0

I am using VS2015 and a Mac build host to create an iOS app.

I have an older iPhone 4 I want to deploy to.

"Launch Failed. The app 'MyApp' could not be launched on 'Old iPhone 4'. Please check the log for more details."

How do I check the logs? I load up xcode on the mac, Window/Devices/View Device Log, but it is empty.

my master page overlap to upper status bar.

$
0
0

my master page overlap to upper status bar. how to overcome top space in master datail page

App crashing on Windows Phone when deplyed in Release mode

$
0
0

Hi,

We have developed a Xamarin Forms app supporting Android, iOS and Windows Phone. The app is working on all three OS when deployed in Debug mode. It's also working on Android and iOS when deployed in Release mode. It crashes immediately after displaying Splash screen on Windows Phone 8.1/10 when deployed with Release mode but strangely all works fine when deployed using Debug mode.

Any idea from experts here?
Is there any way to get see the app log to diagnose the crash reason?

Thank you,
Deepak Sakpal

Why BroadcastReceiver OnReceive() method crashes ?

$
0
0

Hello,
I Have a BroadcastReceiver which receive BOOT_COMPLETED signal and register with GCM.
The app crashes on startup due to this Receiver.

I tried to debug sending BOOT_COMPLETED signal with ADB SHELL. Here are the results

  • When I send a BOOT_COMPLETED signal to the app when it is running = OK, GCM Registered
  • When the app is paused (after pushing the HOME button) ... OK, GCM Registered
  • When the app is stopped (after pushing the BACK button) ... OK, GCM Registered
  • When the app is killed (after pushing the BACK button and pressing CLOSE ALL in "recently used apps") ... CRASH ! ("Unfortunatly, App has stopped") Same as on device's boot.

The problem is that VS ends any debugging process when the app is killed. So it is impossible for me to know what is wrong.
The BroadcastReceiver calls a static method located in the MainActivity class. Maybe that is the problem. Please help :smile:

    [BroadcastReceiver]
    [IntentFilter(new[] { Intent.ActionBootCompleted }, Categories = new[] { "android.intent.category.HOME" })]
    public class StartReceiver : BroadcastReceiver
    {
        public override void OnReceive(Context context, Intent intent)
        {
            MainActivity.RegisterWithGCM();
        }
    }
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
        public static MainActivity instance;

        protected override void OnCreate (Bundle bundle)
        {
            instance = this;

            base.OnCreate (bundle);

            global::Xamarin.Forms.Forms.Init (this, bundle);

            ActionBar.SetIcon(null);
            global::Xamarin.Forms.Forms.SetTitleBarVisibility(Xamarin.Forms.AndroidTitleBarVisibility.Never);

            LoadApplication(new App ());

            RegisterWithGCM();
        }


        public static void RegisterWithGCM()
        {
            // Check to ensure everything's set up right
            GcmClient.CheckDevice(instance);
            GcmClient.CheckManifest(instance);

            // Register for push notifications
            GcmClient.Register(instance, Constants.SenderID);
        }
}

Back button from causes crash on Android when page is MasterDetail

$
0
0

I'm seeing a crash on Android when the user presses the back button on their device while on the root MainPage of the application which happens to be a MasterDetail page. It looks to be the disposing of the Detail page that is the issue.

I'm using Xamarin.Forms 2.3.3-pre3 and building using Android 7.0 SDK.

Here is the stack trace:

  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3819/96c7ba6c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) [0x00084] in /Users/builder/data/lanes/3819/5a02b032/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11464
  at Android.Runtime.JNIEnv.CallIntMethod (System.IntPtr jobject, System.IntPtr jmethod) [0x00000] in /Users/builder/data/lanes/3819/5a02b032/source/monodroid/src/Mono.Android/JNIEnv.g.cs:186
  at Android.Support.V4.App.FragmentTransactionInvoker.CommitAllowingStateLoss () [0x00033] in <27c17fe440cf491ba8255bcefade6e02>:0
  at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailContainer.Dispose (System.Boolean disposing) [0x00042] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\MasterDetailContainer.cs:130
  at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/3819/5a02b032/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203
  at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer.Dispose (System.Boolean disposing) [0x00046] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\MasterDetailPageRenderer.cs:192
  at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/3819/5a02b032/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x0003f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:226
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.Dispose () [0x00010] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:52
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy () [0x0002f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:195
  at Android.App.Activity.n_OnDestroy (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3819/5a02b032/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.App.Activity.cs:2981
  at (wrapper dynamic-method) System.Object:b4f537f5-a711-449c-9bf3-d2540956cdc2 (intptr,intptr)
  --- End of managed Java.Lang.IllegalStateException stack trace ---
java.lang.IllegalStateException: Activity has been destroyed
    at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1515)
    at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:638)
    at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:621)
    at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.n_onDestroy(Native Method)
    at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.onDestroy(FormsAppCompatActivity.java:80)
    at android.app.Activity.performDestroy(Activity.java:6866)
    at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1153)
    at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4154)
    at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4185)
    at android.app.ActivityThread.-wrap6(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1521)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Centering Labels

$
0
0

Is it possible to have two labels, side-by-side, one on the left and the other in the center (horizontally) of the page?

Thank you for your time.


Weird Un-clickable Behavior for RadioButton

$
0
0

NOTE: I have tested it in a pure Xamarin Android project and its working as expected, so I hope if the administrator delete my post in Android forum.

Hi All,

I am using RadioButton widget as selection indicator only. I don't want it to be responsive to user input so I disable its clickable property to false. I will update its value through data binding from Xamarin Forms. However I got a weird behaviour as seen in pictures below. There are extra circles or shadows appeared around radiobutton. Any idea how to remove it? I tried ClearAnimation() but it did not work.

Updated States (with Clickable = true):
<-->

Updated States (with Clickable = false):
<-->

-K

how to connect my Arduino mega with my Xamarin forms application.

$
0
0

hi

how to connect my Arduino mega with my Xamarin forms application, and how to send and receive data between them

Presentation: Xamarin.Forms Performance, Power Controls and Layout System

Emergency: Can't install Microsoft.Bcl.Build.1.0.14 in Visual Studio 2015 for Android project

$
0
0

I am trying to use "PortableRest" for my Xamarin Forms portable projects(IOS project can add PortableRest.3.0.1 fine).
I can't add package "PortableRest.3.0.1" to my Droid project, the following are the error message in output.

I tried on both OS X and Window Xamarin Studio,
Xamarin Studio OS X/Windows doesn't have problem to add "PortableRest.3.0.1" to Android project at all.

I followed an old post said that I need to reinstall Portable library, Xamarin Studio,reboot etc, no matter what I do,
Visual Studio can't add "PortableRest.3.0.1",

Please help, I have been stuck here for few hours already.

Thank you!

=======Output=======
Resolved actions to install package 'PortableRest.3.0.1'
Install failed. Rolling back...
Package 'Microsoft.Bcl.Build.1.0.14 : ' does not exist in project 'App1.Droid'
Package 'Microsoft.Bcl.Build.1.0.14 : ' does not exist in folder 'C:\Users\Dev\Documents\Projects\App1\packages'
Could not install package 'Microsoft.Bcl.Build 1.0.14'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

=======Error=======
Error Could not install package 'Microsoft.Bcl.Build 1.0.14'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0

Managing SignalR Connections in Xamarin.Forms

$
0
0

I recently started experimenting with SignalR for real time updates from a server in Xamarin.Forms. This is my scenario: PageA and PageB both create separate connections in order to receive updates from the server. A user can navigate from PageA to PageB and currently, both connections remain alive.

Questions:
1. Would it be best to disconnect PageA's connection when navigating to PageB and reconnect when PageB is popped off the navigation stack?
2. Should I be using separate connections? (Both use the same HubProxy)
3. When debugging I noticed that there's network activity on the Android client when the app is in the background (I assume this is the case for the iOS client as well). How do I effectively suspend/disconnect all connections when the app is placed in the background and resume/reconnect when it returns to the foreground? How are the Pages/ViewModels made aware of this transition?
4. Similarly, if I use a service like PubNub, where do I place this suspense-resume (subscribe/unsubscribe) logic?

Creating Weekly based DataGrid in xamarin.forms

$
0
0

Hi,
Currently i trying to create weekly date datagrid. Each column will be date and each row will be different tasks. in that i want to access each cell when i click cell the foreground color will be changed. How achieve this kind of datagrid. Here i have attached my screenshot.

Xamarin.Android.Support.Design 23.4.0' is not compatible with 'Xamarin.Forms 2.3.0.107'

$
0
0

Unable to resolve dependencies. 'Xamarin.Android.Support.Design 23.4.0' is not compatible with 'Xamarin.Forms 2.3.0.107'


How to vertically center an item in a grid cell?

$
0
0

I have a ListView item template that contains a grid with 3 columns: an image, a label and another image. All items are have their VerticalOptions set to LayoutOptions.Center. However, the list displays the items vertically aligned to the top, as shown in this image:

ravib.com/download/item.template.vcenter.png

The item template is defined in code as follows:

        // Create list view item template
        this._listOrgs.ItemTemplate = new DataTemplate (() => {

            // Selected indicators
            Image imgSelected = new Image() {
                Aspect = Aspect.AspectFill,
                WidthRequest = 24,
                VerticalOptions = LayoutOptions.Center,
                Source = ImageSource.FromResource("check_yellow_24.png"),
            };
            imgSelected.SetBinding (Image.IsVisibleProperty, "IsSelected");
            imgSelected.SetValue (Grid.ColumnProperty, 0);

            // Label
            Label lblOrgName = new Label() {
                VerticalOptions = LayoutOptions.Center,
                Font = Font.SystemFontOfSize (NamedSize.Large),
                HorizontalOptions = LayoutOptions.StartAndExpand,
            };
            lblOrgName.SetBinding (Label.TextProperty, "Name");
            lblOrgName.SetValue (Grid.ColumnProperty, 1);

            // "Has children" indicator
            Image imgHasChildren = new Image() {
                Aspect = Aspect.AspectFill,
                WidthRequest = 24,
                VerticalOptions = LayoutOptions.Center,
                Source = ImageSource.FromResource("arrow_right_blue_24.png"),
            };
            imgHasChildren.SetBinding (Image.IsVisibleProperty, "HasChildren");
            imgHasChildren.SetValue (Grid.ColumnProperty, 2);

            // Compose view cell
            return new ViewCell {
                View = new Grid {
                    Padding = new Thickness (25.0f, 0, 0, 0),
                    ColumnDefinitions = new ColumnDefinitionCollection() {
                        new ColumnDefinition() { Width=24 },
                        new ColumnDefinition() { Width=GridLength.Auto },
                        new ColumnDefinition() { Width=24 },
                    },
                    Children = { imgSelected, lblOrgName, imgHasChildren }
                }
            };
        });

How do I get the items to display vertically centered? Thanks.

Device Unuque id

$
0
0

Hi,
I want my device UDID for iOS devices and some unique id for android devices that I am using as an tag while registering on notification hub.

My sample code is :

public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
//SBNotificationHub Hub;
var DeviceToken = deviceToken.Description;
Console.WriteLine("Success" + DeviceToken);

        // Get previous device token
        var oldDeviceToken = NSUserDefaults.StandardUserDefaults.StringForKey("PushDeviceToken");

Hub = new SBNotificationHub(ConstantsAzure.ConnectionString, ConstantsAzure.NotificationHubPath);

        if (!string.IsNullOrEmpty(DeviceToken))
        {
            if (oldDeviceToken == null)
            {
                if (!string.IsNullOrWhiteSpace(DeviceToken))
                {
                    DeviceToken = DeviceToken.Trim('<').Trim('>');
                    DeviceToken = DeviceToken.Replace(" ", String.Empty);
                    Console.WriteLine("Success" + DeviceToken);
                }

                Console.WriteLine("Device is not registered, call the registration function here ");

                NSSet tags = new NSSet(new string[] { "dId" + DeviceToken });
                Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) =>
                {
                    if (errorCallback != null)
                        Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());
                    else
                    {
                        Console.WriteLine("Registration success");
                        NSUserDefaults.StandardUserDefaults.SetString(DeviceToken, "PushDeviceToken");
                    }
                });
            }
        }

Is there any way to use the NSUser default in my shared application. OR how can I get the device id in shared application for both android and ios device?

Font properties not reapplied when update of binding context property on iOS app

$
0
0

I have a custom renderer in my Droid project and iOS project which set the font of the text.

From iOS:

[assembly: ExportRenderer(typeof(TestLabel), typeof(IconLabelRenderer))]
namespace FontTest.iOS
{
    public class TestLabelRenderer: LabelRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged(e);
            Control.Font = UIFont.BoldSystemFontOfSize(16.0f);
        }
    }
}

From Droid:

[assembly: ExportRenderer(typeof(TestLabel), typeof(IconLabelRenderer))]
namespace FontTest.Droid
{
    public class TestLabelRenderer : LabelRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged(e);
            Control.Typeface = Typeface.DefaultBold;
        }
    }
}

In my XF project, I have a viewmodel with a binding to the TextColorProperty of the TestLabel.
When the viewmodel property gets updated, the font remains bold (as expected) on Droid but does not remain bold on iOS.

PS: I know XF doesn't need custom renderer to change a text to bold. This is a simple example to illustrate my issue: The font is not reapplied on iOS.

VS 2015 Errors on sample projects

$
0
0

Hi there,

Hope someone can help me. I'm checking out the xamarin-form samples on github. On most projects i get the following 2 errors :

Error Build action 'EmbeddedResource' is not supported by one or more of the project's targets.

Error CS0103 The name 'InitializeComponent' does not exist in the current context.

What are these errors and how can i fix them ?

I always open the samples , restore the nuget packages and also update all packages to latest stable version but i still get the above errors.

Thanks again,
Theuns

TargetType="VisualElement" not work

$
0
0

in app.xaml Definition a style,like this:

<Style TargetType="VisualElement">
<Setter Property="BackgroundColor" Value="Pink" />
</Style>

it not work,but change the TargetType="Label",it is ok.why?

Viewing all 91519 articles
Browse latest View live


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