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

How to Bind a specific Object to a Label?

$
0
0

Hi guys,
Newbie here... I've a Model which contains multiple Objects.
In XAML, I would like to bind my label to a specific object.
How can I do that? Below I'm trying to display the "Name" from the "Student" object:

<StackLayout Margin="20" VerticalOptions="StartAndExpand">

        <Label Text="{Binding Name}" BindingContext={"Student"} />
        ...
</StackLayout>

And here is code snippet of the cs file:

namespace XamlSamples
{
    public partial class MainPage : ContentPage
    {
        string translatedNumber;
        MyModel model = new MyModel();

        public MainPage ()
        {
            InitializeComponent ();
            BindingContext = MyModel;
        }
    }
    class MyModel : INotifyPropertyChanged
    {
        public Student MyStudent{get; set;}

        public University MyUniversity{get; set;}
        ...
    }
}
Class Student
{
    public Name{get; set;}
    public Address{get; set;}
    public Phone{get; set;}
}
Class University
{
    public Name{get; set;}
    public Address{get; set;}
    public Phone{get; set;}
}

Please help.


GetPositionAsync not work in Xamarin Android

$
0
0

Here is the code that I am using.
This code works on IOS but never worked on Android.
I could see some similar issues in their Project but couldn't get any help.

public async Task<Position> GetCurrentLocation()
    {
      Position position = null;
      try
      {
        var locator = CrossGeolocator.Current;
        locator.DesiredAccuracy = 100;

        position = await locator.GetLastKnownLocationAsync();

        if (position != null)
        {
          //got a cahched position, so let's use it.
          return;
        }

        if(!locator.IsGeolocationAvailable || !locator.IsGeolocationEnabled)
        {
          //not available or enabled
          return;
        }

        position = await locator.GetPositionAsync(TimeSpan.FromSeconds(20), null, true);

      }
      catch (Exception ex)
      {
        //Display error as we have timed out or can't get location.
      }

      if(position == null)
        return;

      var output = string.Format("Time: {0} \nLat: {1} \nLong: {2} \nAltitude: {3} \nAltitude Accuracy: {4} \nAccuracy: {5} \nHeading: {6} \nSpeed: {7}",
          position.Timestamp, position.Latitude, position.Longitude,
          position.Altitude, position.AltitudeAccuracy, position.Accuracy, position.Heading, position.Speed);

      Debug.WriteLine(output);
    }

I always get task cancellation exception.

    System.Threading.Tasks.TaskCanceledException: A task was canceled.
          at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00026] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
          at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
          at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
          at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
          at Plugin.Geolocator.GeolocatorImplementation+<GetPositionAsync>d__33.MoveNext () [0x0042a] in C:\projects\geolocatorplugin\src\Geolocator.Plugin.Android\GeolocatorImplementation.cs:206
        --- End of stack trace from previous location where exception was thrown ---
          at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
          at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
          at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
          at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
          at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
          at MtwPublicApp.Services.LocationService+<GetCurrentLocation>d__2.MoveNext ()

Please help me to fix
Thanks!

(iOS) Button Click doesn't get hit when adding Grid layout (xaml)

$
0
0

I created simple blank Xamarin forms project. When I add the Grid layout object to my xaml, button clicks don't get hit. If I remove the grid, button clicks code is getting hit. Any ideas what is wrong?

Note: The code pasted doesn't show the < brackets correctly, I may not be using the correct markdown.

XAML:
<br /> <?xml version="1.0" encoding="utf-8"?><br /> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:BlankForm" x:Class="BlankForm.BlankFormPage"><br /> <Grid ><br /> &lt;Grid.RowDefinitions><br /> <RowDefinition Height="20"/><br /> <RowDefinition Height="*"/><br /> &lt;/Grid.RowDefinitions><br /> &lt;Grid.ColumnDefinitions><br /> <ColumnDefinition Width="53"/><br /> <ColumnDefinition Width="*"/><br /> &lt;/Grid.ColumnDefinitions><br /> <StackLayout Orientation="Vertical" Grid.Row="0" Grid.Column="0"><br /> <Button x:Name="Connection" Text="line" Clicked="Handle_Clicked"/><br /> <Button x:Name="Btn2" Text="Btn2" Pressed="OnPress" Clicked="Handle_Clicked2" ></Button><br /> </StackLayout><br /> </Grid><br /> </ContentPage><br />

Image not showing

$
0
0

Hey guys,

I am trying to make a very basic contentPage with just 2 buttons and an image. But no matter what I am trying, the image does not show .. Am I getting crazy or just missing something ? I made sure to include the image in both iOS and Android's Resource folders!

public class MainMenuPage : ContentPage
    {
        public MainMenuPage ()
        {
            Content = new StackLayout () {
                Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0),
                //Orientation = StackOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children = {
                    new StackLayout(){
                        Orientation = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.FillAndExpand,

                        Children = {
                            new Button(){
                                Text = "Profile",
                                TextColor = Color.FromRgb(161,161,161),
                                BorderColor = Color.FromRgb(161,161,161),
                                BorderWidth = 1,
                                HeightRequest = 50,
                                BorderRadius = 1,
                                HorizontalOptions = LayoutOptions.FillAndExpand,
                            },
                            new Button(){
                                Text = "Skills",
                                TextColor = Color.FromRgb(161,161,161),
                                BorderColor = Color.FromRgb(161,161,161),
                                BorderWidth = 1,
                                HeightRequest = 40,
                                BorderRadius = 1,
                                HorizontalOptions = LayoutOptions.FillAndExpand,
                            },
                        },
                    },
                    new Image () {
                        IsVisible = true,
                        Aspect = Aspect.AspectFit,
                        Source = ImageSource.FromFile ("flint.png"),
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions = LayoutOptions.CenterAndExpand,
                    },
                },
            };
        }
    }

Thanks !

users authentication

$
0
0

hello developers
i create pcl project, i have many users e.g. admin, client ... in one app and one login page .
when the admin login the app should appears admin pages, and so on.
so what i want to know, what the technical use for this.

When do i put on the page a syncfusion listview i get an error

$
0
0

When i try to create a ListView with Syncfusion it throws this error as screenshot shows below

this is page is my login page

public  void Login_Clicked(object sender, EventArgs e)
        {
            LoginService svc = new LoginService();
            LoginRS res = svc.Login(txtUsuario.Text, txtSenha.Text);
            if (res != null && res.Success  )
            {
                App.LooggedUser = res;

                Application.Current.MainPage = new MasterDetailPage
                {
                    Master = new Master(),
                    Detail = new TabbedPage
                    {
                        Children =
                        {
                            new NavigationPage(new Indicadores()){ Title = "Indicadores", BarBackgroundColor = Color.LightGray },
                            new NavigationPage(new PaineisPage()){ Title = "Painéis", BarBackgroundColor = Color.LightGray }
                        }
                    }
                };

                //Application.Current.MainPage = new NavigationPage(new MainPage()) { BarBackgroundColor = Color.LightGray };

                //await Navigation.PushAsync(new MainPage());
            }
            else if(res != null && ! res.Success)
            {
                lblErroLogin.Text = res.Exception;
            }
            else
            {
                lblErroLogin.Text = "Não foi possível realizar o Login, por favor verifique sua conexão com a Internet";
            }
        }

i'm creating listview in the master.xaml(this page is my menu)

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Operacional.Views.Master"
             xmlns:local="clr-namespace:Operacional.ViewModels"
             xmlns:syncfusion="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms"
             Title="Menu"
             Icon="menu_24.png"
             >
    <syncfusion:SfListView x:Name="listView" />

</ContentPage>

How can i solve it?

MediaCapture.InitializeAsync() failes on Xamarin Forms in UWP

$
0
0

I'm trying to grab a Camera preview. So I created a custom render and the code is fairly straight forward in UWP. The following code works fine in a UWP standalone project but fails in an Xamarin environment. The line await Capture.InitializeAsync(); fails with:

public async Task Render(){
MediaCapture Capture;
Capture = new MediaCapture();
await Capture.InitializeAsync();
}

Fails on:

if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION

        UnhandledException += (sender, e) =>
        {
            if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
        };

endif

    }

e returns:

Exception: {System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.UWP.TaskExtensions.<>c.b__2_1(Object e)
at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()}
Handled: false
Message: "Object reference not set to an instance of an object."
Native View: To inspect the native object, enable native code debugging.

Blank white screen in Xamarin Forms

$
0
0

Hi,

I am developing one application in XF. In App.xaml.cs, i have written some thing which is mentioned below and it's pretty straight forward.

public App()
{
    InitializeComponent();
    MainPage = new SplashScreenPage();
}

protected override void OnStart()
{
    MainPage = new LoginPage();
}

While debugging, i can see, the App() constructor called first, then OnStart() gets called. But in practical scenario, i can't see SplashScreenPage(), it directly shows LoginPage().

Before LoginPage(), i can see one blank white screen which is very annoying for end user. Instead of that, i want to show SplashScreen to end user.

In short, i want to avoid that blank white screen from end user. Is it possible what i am trying to achieve in XF ?


local crypt storage system

$
0
0

Hello everyone I'm looking for a way or a technology that will allow me to distribute images but only visible through my application (Xamarin-form) a little like the steam system that allows you to download the game and being able to play it only via steam is pretty much what I need ... I did some research on how encrypted files but without any concrete results
Thanks for reading me

Listview with grouping :System.ArgumentOutOfRangeException: Index was out of range

$
0
0

Hello,
I'm starting xamarin and i'm facing a binding problem trying to pupulate a listview .
Here is my contentPage:

                RootMenuViewModel rootUserProfileViewModel;
                public RootMenuPage(RootPage rootPage)
                {
                    BindingContext = rootUserProfileViewModel = new RootMenuViewModel(this);
                    LoadUI();
                }

            private void LoadUI()
                {
                listView = new ListView
                        {
                            HasUnevenRows=true,
                            BindingContext = rootUserProfileViewModel,
                            IsGroupingEnabled= true,
                            GroupDisplayBinding = new Binding("GroupName"),
                            ItemTemplate = new DataTemplate(() => {
                                TextCell c = new TextCell();
                                c.SetBinding(TextCell.TextProperty, "Label");
                                return c;
                            }),
                            SeparatorVisibility = SeparatorVisibility.Default
                        };
                     listView.SetBinding(ListView.ItemsSourceProperty, "GroupedClassif");

                              ...
                              ...
                               Content = mystackLayout;

                       }

                }
              protected override async void OnAppearing()
            {
                base.OnAppearing();
                await rootUserProfileViewModel.LoadDataAsync();
            }

My viewModel:

                                   class RootMenuViewModel : BaseViewModel
                                    {
                                           public ObservableCollection<ItemClassification> Classif { get; set; }
                                           public ObservableCollection<ItemClassificationGroups> GroupedClassif { get; set; }
                                           public async Task LoadDataAsync()
                                             {
                                                 //Load data here and create groups:  GroupedClassif  is filled here
                                              }
                                            public class ItemClassificationGroups: ObservableCollection<ItemClassification>
                                           {
                                                public string GroupName { get;set; }
                                                public ItemClassificationGroups(string groupName)
                                                {
                                                    this.GroupName = groupName;
                                                }
                                                }
                                      }

And here the stck trace:

Unhandled Exception:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

02-14 01:49:31.657 I/MonoDroid( 5396): UNHANDLED EXCEPTION:
02-14 01:49:31.658 I/MonoDroid( 5396): System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
02-14 01:49:31.658 I/MonoDroid( 5396): Parameter name: index
02-14 01:49:31.658 I/MonoDroid( 5396): at (wrapper dynamic-method) System.Object:0b998932-4691-46e8-aa30-ea58409493d0 (intptr,intptr)
02-14 01:49:31.658 I/MonoDroid( 5396): at (wrapper managed-to-native) Java.Interop.NativeMethods:java_interop_jnienv_call_nonvirtual_void_method_a (intptr,intptr&,intptr,intptr,intptr,Java.Interop.JniArgumentValue)
02-14 01:49:31.658 I/MonoDroid( 5396): at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue
args) [0x00073] in :0
02-14 01:49:31.658 I/MonoDroid( 5396): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in :0
02-14 01:49:31.658 I/MonoDroid( 5396): at Android.Widget.BaseAdapter.NotifyDataSetChanged () [0x0000a] in :0
02-14 01:49:31.658 I/MonoDroid( 5396): at Xamarin.Forms.Platform.Android.ListViewAdapter.OnDataChanged () [0x00034] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:563
02-14 01:49:31.658 I/MonoDroid( 5396): at Xamarin.Forms.Platform.Android.ListViewAdapter.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:553

Thanks you in advance...

#if __IOS__ seems not working

$
0
0

I used this code in my app, but when it was running, it didn't print the text(both in simulator and my device).

#if __IOS__
            System.Diagnostics.Debug.WriteLine ("I'm in iOS");
#endif

The Define Symbols of my project is DEBUG;MOBILE;IOS;.

The same issue occurs in all the solution I created.
I found that the run menu is different between my solution and MobileCRM, just as the following images shows:

  • My solution: image
  • MobileCRM: image

PinchGestureRecognizer Only Works on Android API Level 19+

$
0
0

Hello,

It looks like that bug that was fixed in 2.3.0 is now occuring again in version 2.5.0.122203. Here is the original bugzilla issue:

https://bugzilla.xamarin.com/show_bug.cgi?id=36447

You can reproduce the crash with the Xamarin PinchGesture sample running on API lower than 19.

Could someone please look into that? Are there any workarounds? I really do not want to disable the ability to zoom for people with low API level, especially since it had worked before. My app uses Minimum Android version API Level 15 (Android 4.0.3 Ice Cream Sandwich) and I am getting crash reports from users with API between 15 and 19.

Thank you.

Forms9Patch: Simplify multi-device image management in your PCL Xamarin.Forms mobile apps

$
0
0

Announcement of Form9Patch

Xamarin Forms is great for developing apps on Android and iOS but it is missing two important tools for developers: scalable images and PCL multi-screen image management. Android developers use NinePatch bitmaps and the drawable directory naming convention for this purpose. Likewise, iOS developers use ResizeableImageWithCapInsets and the @2x, @3x, @4x file naming convention for this purpose.

Forms 9 Patch enhances Xamarin Forms to enable multi-resolution / multi-screen image management to PCL apps for iOS and Android.

What is it?

Simply stated, Forms9Patch is two separate elements (Image and ImageSource) which are multi-screen / multi-resolution extensions of their Xamarin Forms counterparts.

Forms9Patch.ImageSource

Xamarin Forms provides native iOS and Android multi-screen image management (described here). This requires storing your iOS images using the native iOS schema and storing your Android images using the Android schema. In other words, duplicative efforts to get the same results on both Android and iOS. Forms9Patch.ImageSource extends Xamarin.Forms.ImageSource capabilities to bring multi-screen image management to your PCL assemblies - so you only have to generate and configure your app's image resources once. Forms9Patch.ImageSource is a cross-platform implementation to sourcing multi-screen images in Xamarin Forms PCL apps as embedded resources.

Forms9Patch.Image

Forms9Patch.Image compliments Xamarin.Forms.Image to provide Xamarin Forms with a scaleable image element. Scalable images are images that fill their parent view by stretching in designated regions. The source image for the Forms9Patch.Image element can be specified either as a Forms9Patch.ImageSource or a Xamarin.Forms.ImageSource. Supported file formats are NinePatch (.9.png), .png, .jpg, .jpeg, .gif, .bmp, and .bmpf.

Example code

After adding the file bubble.9.png to your PCL project assembly as an EmbeddedResource, you can display it using something like the following:

var bubbleImage = new Forms9Patch.Image () {
    Source = ImageSource.FromResource("MyDemoApp.Resources.bubble.9.png"),
    HeightRequest = 110,
}
var label = new label () {
    Text = "Forms9Path NinePatch Image",
    HorizontalOptions = LayoutOptions.Center,
}

Example XAML

In Xamarin Forms, access to embedded resources from XAML requires some additional work. Unfortunately, Forms9Patch is no different. As with Xamarin Forms, you will need (in the same assembly as your embedded resource images) a simple custom XAML markup extension to load images using their ResourceID.

    [ContentProperty ("Source")]
    public class ImageMultiResourceExtension : IMarkupExtension
    {
        public string Source { get; set; }

        public object ProvideValue (IServiceProvider serviceProvider)
        {
            if (Source == null)
                return null;

            // Do your translation lookup here, using whatever method you require
            var imageSource = Forms9Patch.ImageSource.FromMultiResource(Source);

            return imageSource;
        }
    }

Once you have the above, you can load your embedded resource images as shown in the below example. Be sure to add a namespace for the assembly that contains both your MarkupExtension and your EmbeddedResources (local in the below example).

<?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:MyXamlDemo;assembly=MyXamlDemo"
    x:Class="MyXamlDemo.MyPage"
    Padding="5, 20, 5, 5">
    <ScrollView>
        <ScrollView.Content>
            <StackLayout>
            <Label Text="Xamarin.Image"/>
            <Image Source="{local:ImageMultiResource Forms9PatchDemo.Resources.image}"/>
            </StackLayout>
        </ScrollView.Content>
    </ScrollView>
</ContentPage>

Where to learn more

Project page: http://Forms9Patch.com
Nuget page: https://www.nuget.org/packages/Forms9Patch/0.9.1
Demo app repository: https://github.com/baskren/Forms9PatchDemo

[iOS] ArgumentNullException: Parameter name: image

$
0
0

Hi everyone,

I developed until now my Forms app only on Android and wanted to port it now for iOS, but when launching I only get this exception:

System.ArgumentNullException Argument cannot be null. Parameter name: image

in Main.cs at UIApplication.Main(args, null, "AppDelegate");

Does anyone know why this is happening?

Circular button

$
0
0

Is it possible to create a circular image button?

Thanks


Content Page Secondary Toolbar Items in iOS same as Android

$
0
0

I am using secondary toolbar items in my content page. I want the same menu items in iOS as in android. By default it is showing under navigation bar. How can I achieve this.

(iOS) XF 2.5.0.122203: Object reference not set to an instance of an object

$
0
0

I upgraded to XF 2.5 and on iOS, I get this exception in the XF internal code when updating my ObservableCollection. Is this a known new bug?

  Object reference not set to an instance of an object
    at Xamarin.Forms.Platform.iOS.EventTracker.LoadRecognizers () [0x0005d] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.EventTracker.OnElementChanged (System.Object sender, Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs e) [0x0004e] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) [0x0002c] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.FrameRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) [0x00000] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00118] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.RendererPool.UpdateRenderers (Xamarin.Forms.Element newElement) [0x0008c] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.RendererPool.UpdateNewElement (Xamarin.Forms.VisualElement newElement) [0x00080] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00050] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnRendererElementChanged (System.Object sender, Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs args) [0x0001c] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e) [0x0002c] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00118] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.ListViewRenderer+UnevenListViewDataSource.CalculateHeightForCell (UIKit.UITableView tableView, Xamarin.Forms.Cell cell) [0x00035] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.ListViewRenderer+UnevenListViewDataSource.GetEstimatedRowHeight (UIKit.UITableView table) [0x0008c] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateEstimatedRowHeight () [0x0006c] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateItems (System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Int32 section, System.Boolean resetWhenGrouped) [0x000bc] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <13d193f5a21b4e309afc67e0a5508db5>:0
    at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in D:\agent\_work\1\s\Xamarin.Forms.Core\TemplatedItemsList.cs:771
    at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Boolean fixWindows) [0x0001a] in D:\agent\_work\1\s\Xamarin.Forms.Core\TemplatedItemsList.cs:981
    at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in D:\agent\_work\1\s\Xamarin.Forms.Core\TemplatedItemsList.cs:968
    at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in D:\agent\_work\1\s\Xamarin.Forms.Core\ListProxy.cs:233
    at Xamarin.Forms.ListProxy+<>c__DisplayClass33_0.<OnCollectionChanged>b__0 () [0x00018] in D:\agent\_work\1\s\Xamarin.Forms.Core\ListProxy.cs:206
    at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x000a0] in D:\agent\_work\1\s\Xamarin.Forms.Core\ListProxy.cs:225
    at Xamarin.Forms.ListProxy+WeakNotifyProxy.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00031] in D:\agent\_work\1\s\Xamarin.Forms.Core\ListProxy.cs:394
    at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000f] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:288
    at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:351
    at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x00024] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:219
    at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.6.1.3/src/mono/mcs/class/referencesource/mscorlib/system/collections/objectmodel/collection.cs:67
    at EnergyAlert.Pages.ArticlesPage+<LoadNextPage>d__69.MoveNext () [0x00252] in /TFS/Mobile/Applications/EnergyAlert/EnergyAlert.Shared/Pages/ArticlesPage.cs:431

How to working Countdown Timer in cross-platform that means xamarin.Forms(Android ,IOS and windows)

$
0
0

How to working Countdown Timer in cross-platform that means xamarin.Forms(Android ,IOS and windows)?
I want to countdown timer for quiz ,that working in portable.And i want reference of "System.Timer".Please share your Answer......

Countdown Timer in Xamain.Forms App

$
0
0

I am trying to convert Xamarin.Android app to Xamarin.Forms, I nedd to have a countdown timer for exam format which will keep updating a label while we use the app. Once timer goes off message is displayed and another activity is opened. I had used follwoing code for Xamarin.Android app.

Can anyone help me understand how i can add this functionality to xamarin.forms app.

   public delegate void TickEvent(long millisUntilFinished);
     public delegate void FinishEvent();

    public class CountDown : CountDownTimer
    {
        public event TickEvent Tick;
        public event FinishEvent Finish;

        Activity m_owner;
        public CountDown(long totaltime, long interval, Activity owner): base(totaltime, interval)
        {
                m_owner = owner;
        }
        public override void OnTick(long millisUntilFinished)
        {
            if (Tick != null)
            Tick(millisUntilFinished);
                long millis = millisUntilFinished;
                long hours = millis / (60 * 60 * 1000);
                long min = (millis / (60 * 1000)) % 60;
                long sec = (millis / 1000) % 60;
                TextView txtTime = m_owner.FindViewById<TextView>(Resource.Id.textTime);
                txtTime.Text = hours.ToString("00") + ":" + min.ToString("00") + ":" + sec.ToString("00");
        }
        public override void OnFinish()
        {
            var bulider = new AlertDialog.Builder(m_owner);
            bulider.SetMessage("Exam Time over");
            bulider.SetCancelable(false);
            bulider.SetPositiveButton("OK", delegate { });
            var dialog1 = bulider.Create();
            dialog1.Show();
            int res = 0;

            //start another activity
            m_owner.StartActivity (intent);

            if (Finish != null)
                Finish();
    }

How to use timer in xamarin forms

$
0
0

I found DispatcherTimer in wp8 Or Timer in Andoir could achieve the timer task.
I need to countdown time to update UI in xamarin forms.
any way can I write for forms instead implement all platforms?

Viewing all 89864 articles
Browse latest View live


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