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

Could not link assemblies. Reason: Object reference not set to an instance of an object.

$
0
0

I have a Xamarin.Forms solution, but after some cleaning & building I'm unable to compile my Xamarin.iOS project anymore.
This project was recently migrated from PCL to a .NET Standard 1.6 project in VS2017, and compiled sucessfully in earlier builds. I was able to compile and run in iOS Simultator in Debug Mode, but after some cleaning and building (and adding and removing some nuget packages) i can't run in this mode either.

This is part of the Build log:

Environment variables being passed to the tool:
2>  Xamarin.iOS 11.6.1 using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.2.sdk
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(777,3): error : Could not link assemblies. Reason: Object reference not set to an instance of an object
2>  Tool /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch execution finished.
2>  MTouch: 2017-12-28T11:56:33.4882016-07:00 - Finalizado
2>Ejecución de la tarea "MTouch" terminada -- ERROR.
2>Compilación terminada del destino "_CompileToNative" en el proyecto "AppConsume.iOS.csproj" -- ERROR.
2>
2>ERROR al compilar.
2>
2>"C:\_Fuentes\AppConsume\AppConsume\AppConsume.iOS\AppConsume.iOS.csproj" (destino predeterminado) (1) ->
2>(_CoreCompileImageAssets destino) -> 
2>  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(1198,3): warning : The app icon set "AppIcons" has an unassigned child.
2>
2>
2>"C:\_Fuentes\AppConsume\AppConsume\AppConsume.iOS\AppConsume.iOS.csproj" (destino predeterminado) (1) ->
2>(_CompileToNative destino) -> 
2>  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(777,3): error : Could not link assemblies. Reason: Object reference not set to an instance of an object

Any ideas?
Here it is part of the About information:

                > Microsoft Visual Studio Community 2017 
                Versión 15.5.2
                VisualStudio.15.Release/15.5.2+27130.2010
                Microsoft .NET Framework
                Versión 4.6.01590
                
                Versión instalada: Community
                
                Visual Basic 2017   00369-60000-00001-AA053
                Microsoft Visual Basic 2017
                
                Visual C# 2017   00369-60000-00001-AA053
                Microsoft Visual C# 2017
                
                Administrador de paquetes NuGet   4.5.0
                Administrador de paquetes NuGet de Visual Studio. Para obtener más información acerca de NuGet, visite http://docs.nuget.org/.
                
                Herramientas comunes de Windows Azure   1.10
                Ofrece servicios comunes para su uso con los servicios móviles de Microsoft Azure y Microsoft Azure Tools.
                
                Herramientas de entrega continua de Microsoft para Visual Studio   0.3
                Configuración simplificada de la integración y la entrega continuas de compilaciones desde el IDE de Visual Studio.
                
                Mono Debugging for Visual Studio   4.8.4-pre (3fe64e3)
                Support for debugging Mono processes with Visual Studio.
                
                Visual Studio Tools para aplicaciones Windows universales   15.0.27128.01
                Visual Studio Tools para aplicaciones Windows universales permite crear una experiencia de aplicación universal sencilla para todos los dispositivos que ejecutan Windows 10: teléfono, tableta, PC y más. Incluye el kit de desarrollo de software de Microsoft Windows 10.
                
                VisualStudio.Mac   1.0
                Mac Extension for Visual Studio
                
                Xamarin   4.8.0.753 (6575bd113)
                Extensión de Visual Studio para habilitar la implementación de Xamarin.iOS y Xamarin.Android.
                
                Xamarin Designer   4.8.188 (c5813fa34)
                Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
                
                Xamarin.Android SDK   8.1.0.25 (HEAD/d8c6e504f)
                Xamarin.Android Reference Assemblies and MSBuild support.
                
                Xamarin.iOS and Xamarin.Mac SDK   11.6.1.2 (6857dfc)
                Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

How do I add an event handler to a custom control

$
0
0

I'm implementing a custom checkbox control in my application. I've used the CheckboxImage control proposed by Ali Syed as a starting point in this forum post (https://forums.xamarin.com/discussion/17420/how-to-add-checkbox-control-in-XAML) and added a bindable text property and bindable boolean property.

I want to be able to add an event to the control such that in a code behind or view model I can call a method when the checkbox is checked. Something to the effect of:
<!--In XAML--> <local:CheckBoxImage OnChecked="cb_checked"/>

//Called Method
private void cb_checked(object sender, EventArgs e)
{
    //Do some logic here
 }

My Checkbox class is as follows:

    public class CheckBoxImage : ContentView
    {  
        private Label lblText = new Label() { VerticalOptions=LayoutOptions.Center };

        private Image image = new Image();

        public static BindableProperty TextLblProperty = BindableProperty.Create(
                declaringType: typeof(CheckBoxImage),
                propertyName: "TextLbl",
                returnType: typeof(string),
                defaultValue: "",
                defaultBindingMode: BindingMode.OneWay,
                propertyChanged: HandleLblPropertyChanged);

        private static void HandleLblPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var checkbox = (CheckBoxImage)bindable;
            checkbox.TextLbl = (string)newValue;
            checkbox.lblText.Text = (string)newValue;
        }

        public string TextLbl
        {
            get { return (string)GetValue(TextLblProperty); }
            set { SetValue(TextLblProperty, value); }
        }

        public static BindableProperty IsCheckedProperty = BindableProperty.Create(
                declaringType: typeof(CheckBoxImage),
                propertyName: "IsChecked",
                returnType: typeof(bool),
                defaultValue: false,
                defaultBindingMode: BindingMode.TwoWay,
                propertyChanged: HandleCheckBoxPropertyChanged);

        public bool IsChecked
        {
            get { return (bool)GetValue(IsCheckedProperty); }
            set { SetValue(IsCheckedProperty, value); }
        }

        private static void HandleCheckBoxPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var checkbox = (CheckBoxImage)bindable;
            checkbox.HandleImageChange();
        }

        public CheckBoxImage()
        {
            Resources = new ResourceDictionary();
            Resources.Add("ImageName", "testApp1.check_off.png");

            var resourceName = Resources["ImageName"];

            image.Source = ImageSource.FromResource(resourceName.ToString());
            StackLayout stklayout = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Children = {
            lblText,
            image
        }
            };

            TapGestureRecognizer t = new TapGestureRecognizer();
            t.Tapped += OnScreenTapped;
            stklayout.GestureRecognizers.Add(t);

            Content = stklayout;
        }

        public void OnScreenTapped(object sender, EventArgs args)
        {
            IsChecked = !IsChecked;
            HandleImageChange();
        }

        private void HandleImageChange()
        {
            var resourceName = Resources["ImageName"];
            if (IsChecked)
            {
                Resources["ImageName"] = "testApp1.check_on.png";
                image.Source = ImageSource.FromResource("testApp1.check_on.png");
            }
            else
            {
                Resources["ImageName"] = "testApp1.check_off.png";
                image.Source = ImageSource.FromResource("testApp1.check_off.png");
            }
        }
    }

If someone could show me how to achieve that or point me to the right documentation, I'd appreciate it.

Animation Problem with Xamarin Forms

$
0
0

So I've added a small animation to one of my content pages so when the page loads one of the buttons beats for a second.

I have used the code below :

    protected override async void OnAppearing()
        {
            base.OnAppearing();

            await EditBalance.ScaleTo(1.25, 184);
            await EditBalance.ScaleTo(1, 184);
    }

This worked fine when I tested it on IOS but when I tried to run it on Android I got the following Exception:

04-17 21:27:31.627 E/mono    ( 1347): System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.
04-17 21:27:31.627 E/mono    ( 1347):   at System.Threading.Tasks.TaskCompletionSource`1[TResult].SetResult (TResult result) [0x00013] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.ViewExtensions+<>c__DisplayClass8_0.<ScaleTo>b__1 (System.Double f, System.Boolean a) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\ViewExtensions.cs:166 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions+<>c__DisplayClass13_0`1[T].<AnimateInternal>b__1 (System.Double f, System.Boolean b) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:176 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions.AbortAnimation (Xamarin.Forms.AnimatableKey key) [0x00052] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:150 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions.AnimateInternal[T] (Xamarin.Forms.IAnimatable self, System.String name, System.Func`2[T,TResult] transform, System.Action`1[T] callback, System.UInt32 rate, System.UInt32 length, Xamarin.Forms.Easing easing, System.Action`2[T1,T2] finished, System.Func`1[TResult] repeat) [0x00024] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:171 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions+<>c__DisplayClass7_0`1[T].<Animate>b__0 () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:100 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions.Animate[T] (Xamarin.Forms.IAnimatable self, System.String name, System.Func`2[T,TResult] transform, System.Action`1[T] callback, System.UInt32 rate, System.UInt32 length, Xamarin.Forms.Easing easing, System.Action`2[T1,T2] finished, System.Func`1[TResult] repeat) [0x0009c] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:108 

I have been able to work round the issue by changing the code to:

        protected override async void OnAppearing()
        {
            base.OnAppearing();

            await EditBalance.ScaleTo(1.25, 184).ContinueWith(t => EditBalance.ScaleTo(1, 184));
    }

Which worse but seems a little dirty. Has anyone experienced this or had a similar issue, and had a better work around?

Cheers ....

Does anybody know if is only possible use List string with XfxComboBox ?

Anyone know an alternative to TintedImage nuget (now that it is no longer maintained)?

[You need to increase the $(TargetFrameworkVersion) for your project] warning

$
0
0

After upgrading Visual Studio 2017 to version 15.8, my android project is getting the following warning:

The $(TargetFrameworkVersion) for App3.Android.dll (v9.0) is greater than the $(TargetFrameworkVersion) for your project (v8.1). You need to increase the $(TargetFrameworkVersion) for your project

To reproduce this error:
1. Create a new "Mobile App (Xamarin.Forms)" project with Code Sharing Strategy using ".NET Standard"
2. Build the project

In my project's Properties->Application, Compile using Android version: Android 8.1 (Oreo)
And in my Android Manaifest, Target Android version: Android 8.1 (API Level 27-Oreo)
And in my project csproj, AndroidUseLatestPlatformSdk is set to false

Anyone encountered this warning?

The LinkAssemblies task failed unexpectedly.- Xamarin.Forms (Android)

$
0
0

I have one project in xamarin forms with following configurations:

Xamarin Forms Version: 2.3.3.193
Compile using Android version: version 15 or above whatever
Minimum Android version: Use Compile using SDK version
Target Android version: User Compile using SDK version
Debugger: .Net(Xamarin)

Build Configuration
Platform Target: Any CPU

I got this error.

Error The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'System.Void FAB.Droid.FloatingActionButtonRenderer::SetBackgroundColors()' in assembly: 'FAB.Droid.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Support.Design.Widget.FloatingActionButton::SetRippleColor(System.Int32)
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() HalalApps.Droid

This error is was running very much fine but don't know some time unexpectedly this error come.

Xamarin.Forms CardsView nuget package

$
0
0

Hi all) I've released new package for Xamarin.Forms (Something like Tinder's CardsView)
Maybe, someone will be interested in it

nuget.org/packages/CardsView/ -- nuget
github.com/AndreiMisiukevich/CardView -- source and samples


When I Try to Create a Custom ViewCell I Get an Error?

$
0
0

Hi. I need to create a Custom VewCell so that i can reuse the code within it multiple times.
but i get these erros :

Error CS0234 The type or namespace name 'DateCell' does not exist in the namespace 'Xamarin.Forms' (are you missing an assembly reference?)

Error XLS0414 The type 'DateCell' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built

This is the code for the Xaml that i use :

            <?xml version="1.0" encoding="utf-8" ?>
            <DateCell 
                         x:Class="App31.DateCell"
                         xmlns="http://xamarin.com/schemas/2014/forms"
                         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                         >

                <StackLayout Orientation="Horizontal" Padding="14, 0">
                    <Label Text="Time" VerticalOptions="Center"/>
                    <TimePicker HorizontalOptions="EndAndExpand" />
                </StackLayout>

            </DateCell> 

and here is the code behind

                    using System;
                    using System.Collections.Generic;

                    using Xamarin.Forms;


                    namespace App31.Extensions
                    {

                        public partial class DateCell : ViewCell
                        {
                            public DateCell()
                            {
                                InitializeComponent();
                            }
                        }

                    }

How can I resolve this issue?
Thanks .

How to Attach Debugger to a Running Android or IOS app?

$
0
0

I often start an app just to see how it works, then I decide to debug, so I just attach to its process and debugging kicks in.

But I am not able to find how to attach to a running Xamarin Forms app process to start debugging.

To clarify, I know how to debug and that works fine but how do I attach debugger to a running Xamarin Forms app to debug?

error : Failed to resolve assembly: 'System, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

$
0
0

I have a PCL Net Standard 1.6 based multi-project solution. It built ok until I decided to add a xaml based ContentPage. Now it just tells me when compiling the PCL:

error : Failed to resolve assembly: 'System, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

I done multiple cleans, restarts, cbproj file compares, bin and obj directory deletion (the usual sort of stuff I have to do to keep VS2017 with Xamarin running) but nothing can get rid of this error. Plus many hours Googling

(I'm only doing this because FlexLayout does not expose the Grow property so I can't design a FlexLayout based GUI in C# - my preferred way of doing GUI)

At a lost and welcome suggestions

System.ObjectDisposedException: Can't access disposed object. Object name: 'Android.Graphics.Bitmap'

$
0
0

Here is the stack trace

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Android.Graphics.Bitmap'.
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in /Users/builder/data/lanes/4468/b16fb820/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.cs:153
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00002] in /Users/builder/data/lanes/4468/b16fb820/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:11
at Android.Graphics.Bitmap.Recycle () [0x00000] in /Users/builder/data/lanes/4468/b16fb820/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Android.Graphics.Bitmap.cs:975
at Xamarin.Forms.Platform.Android.ButtonDrawable.Reset () [0x00008] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ButtonDrawable.cs:55
at Xamarin.Forms.Platform.Android.ButtonRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs1[TElement] e) [0x00067] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ButtonRenderer.cs:110 at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000f4] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:196
at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:137 at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x0003a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:91 at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00104] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:217 at Xamarin.Forms.Platform.Android.VisualElementPackager.<.ctor>b__6_0 (System.Object sender, Xamarin.Forms.Platform.Android.VisualElementChangedEventArgs args) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:29 at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs1[TElement] e) [0x00031] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:292 at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000f4] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:196
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:137
at Xamarin.Forms.Platform.Android.ViewCellRenderer+ViewCellContainer.Update (Xamarin.Forms.ViewCell cell) [0x00093] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Cells\ViewCellRenderer.cs:102
at Xamarin.Forms.Platform.Android.ViewCellRenderer.GetCellCore (Xamarin.Forms.Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context) [0x00011] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Cells\ViewCellRenderer.cs:18
at Xamarin.Forms.Platform.Android.CellRenderer.GetCell (Xamarin.Forms.Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context) [0x00063] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Cells\CellRenderer.cs:51
at Xamarin.Forms.Platform.Android.CellFactory.GetCell (Xamarin.Forms.Cell item, Android.Views.View convertView, Android.Views.ViewGroup parent, Android.Content.Context context, Xamarin.Forms.View view) [0x00023] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Cells\CellFactory.cs:20
at Xamarin.Forms.Platform.Android.ListViewAdapter.GetView (System.Int32 position, Android.Views.View convertView, Android.Views.ViewGroup parent) [0x001d7] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:258
at Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_ (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 position, System.IntPtr native_convertView, System.IntPtr native_parent) [0x0001a] in /Users/builder/data/lanes/4468/b16fb820/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Android.Widget.BaseAdapter.cs:443
at at (wrapper dynamic-method) System.Object:547b43a6-8c3b-4ca3-8c70-6d5cccce980b (intptr,intptr,int,intptr,intptr)

Here is my xaml

<?xml version="1.0" encoding="UTF-8"?>





<?xml version="1.0" encoding="UTF-8"?>

        <Button StyleId="load" Text="Load" Font="Medium" 
            MinimumWidthRequest="60" MinimumHeightRequest="25"
            BackgroundColor="{l:GlobalResource DefaultButtonBackground}" 
            TextColor="{l:GlobalResource DefaultButtonText}" 
            Clicked="LoadClicked" CommandParameter="{Binding Location}" />
        <Label TextColor="{l:GlobalResource LightestText}"
            HorizontalOptions="FillAndExpand" VerticalOptions="Center" 
            Text="{Binding Location.DisplayName}"/>
        <Button Clicked="LocationSelected" CommandParameter="{Binding Location}"
            BackgroundColor="{l:GlobalResource TransparentBackground}" 
            MinimumWidthRequest="20" WidthRequest="20" 
            HorizontalOptions="Center" VerticalOptions="Center" 
            Image="disclosure.png" IsVisible="{Binding Location.Show}"/>

</StackLayout>

<?xml version="1.0" encoding="UTF-8"?>

<ContentPage.Content>











</ContentPage.Content>

    public CurrentLoad()
    {

        InitializeComponent();
        Device.BeginInvokeOnMainThread( () => {
            VehiclePickupList.ItemTemplate = new DataTemplate(typeof(VehiclePickupCell));
            VehiclePickupList.GroupHeaderTemplate = new DataTemplate(typeof(VehiclePickupCellHeader));
            VehiclePickupList.ItemsSource = ViewModel.VehiclesGroupedByPickup;

            VehicleDeliveryList.ItemTemplate = new DataTemplate(typeof(VehicleDeliveryCell));
            VehicleDeliveryList.GroupHeaderTemplate = new DataTemplate(typeof(VehicleDeliveryCellHeader));
            VehicleDeliveryList.IsVisible = false;
            VehicleDeliveryList.ItemsSource = ViewModel.VehiclesGroupedByDropoff;
        });

        ......
    }

can someone shed some light why i get the exception on the disposed object please?

Custom controls and EventHandler

$
0
0

Hi all,

I'm working with Forms and I have to create a custom view to display a side menu button item.

I have this structure:

XAML View:
- SideMenuView.xaml
- SideMenuItemView.xaml

Code Behind class:
- SideMenuController.cs
- SideMenuItemController.cs

This is the Custom Control:

        < ?xml version="1.0" encoding="utf-8" ?>
        < StackLayout>

            <Label x:Name="selectedOption"  Text=" " BackgroundColor="Gray" VerticalOptions="Center" />

            <Button 
                x:Name="buttonItem" 
                Text="{Binding ButtonText}" 
                BackgroundColor="{x:Static resx:AppConstants.TransparentColor}"
                BorderColor="{x:Static resx:AppConstants.TransparentColor}"
                HorizontalOptions="Start"
                />

            <Label x:Name="menuOption" Text="{Binding TextCount, StringFormat='({0})'}" VerticalOptions="Center" Font="{x:Static resx:AppConstants.LabelFont}"/>

        < /StackLayout >

Actually ButtonText and TextCount attributes are working well.
If you look at the following line I'm adding my custom control in that way:

<control:SideMenuItemControl ButtonText="{x:Static resx:AppResources.SideMenuGoing}" TextCount="{Binding SideMenuOptionsViewModel.Going, StringFormat='({0})'}" ClickedHandler="DoSomething" />

And this is the event:

private void DoSomething(object sender, EventArgs args) { App.sideMenuController.Detail = new NewViewController(); App.sideMenuController.IsPresented = false; }

So I need a way to create a custom attribute named ClickedHandler on SideMenuItemController that receives "DoSomething" method.

Have you any idea about a solution? I have some time working with this and I can't make it work.

Regards,

Get Phone number in Xamarin.Forms

Device.GetAssemblies

$
0
0

I'm trying to do some stuff with reflection, but in order to make it practical I really need to be able to list all of the loaded assemblies. After failing to find a way to get that list in a PCL it occurred to me that Xamarin.Forms does this somehow in order to associate renderers with their elements. I dug around and discovered that there is a method in Device called GetAssemblies (exactly what I need!), but it's internal! Argh! Its implementation uses Device.PlatformServices, which is also internal. Just about everything in the IPlatformServices method looks extremely useful. Please make these public!

In the meantime the only thing I can think of to work around this is to initialize the component from the platform-specific code, right after Forms.Init. That sucks. :(


Entry.Focus() Not Working For Android

$
0
0

Hello,

Currently, I am using this setup to set focus to an Entry:

protected override void OnAppearing()
{
    base.OnAppearing();

    Entry emailEntry = this.FindByName<Entry>("emailEntry");
    emailEntry.Focus();
}

The Entry is part of a StackLayout. So on the iOS emulator it focuses on the entry and brings up a keyboard. On the Android emulator, however, it just sets focus to the entry, but does not bring up the keyboard. I've noticed other people having the same issues in the forums, but couldn't find an answer or workaround. Are there currently any plans to fix this, and what is a workaround I can use?

Thanks

Device.StartTimer returns false but still goes back into the timer

$
0
0

I don't get what's going on, I return a false value to stop the timer, but in my if statement if I add the "count == 2", then the time still goes, regardless of the fact that I returned a false value!

`
public void StartTimer(UserModel selectedItem)
{
//add one every time user presses button.
count++;

        Device.StartTimer(TimeSpan.FromMilliseconds(1000), () =>
            {

                ////if the count is less than one then start timer
                if (count <= 1)
                {
                    //start the stopwatch
                    timeElapsed.Start();
                }

                ////update text to show the current time spent on task.
                selectedItem.DateTimeSet = string.Format("{0:00}:{1:00}:{2:00} ", timeElapsed.Elapsed.Hours, timeElapsed.Elapsed.Minutes, timeElapsed.Elapsed.Seconds) + IsAmOrPM;

                //if objects are not same then this means user has selected a new object and must stop the timer
                if (selectedItem.Id == um.Id && count == 2)
                {
                   // count = 0;
                   // //stop the stopwatch as item clicked on has changed
                   // timeElapsed.Stop();

                   // //format the time spent
                   // selectedItem.DateTimeSet = "test"; //"Time Spent: " + timeElapsed.Elapsed.Hours + " Hours " + timeElapsed.Elapsed.Minutes + " Minutes " + timeElapsed.Elapsed.Seconds + " seconds ";

                   // //update item so it shows next text
                   //dbhelper.UpdateItem(selectedItem);

                    //set to 0 so when user presses on item its starts at 0 and not at a previous value
                    //   timeElapsed.Reset();

                    return false;
                }          

                return true;
            });
    }

`

speech to text

$
0
0

is there any class library is available to convert speech to text

Override volume and silent mode on iOS and Android

$
0
0

Hi,

I would like to override selected volume and silent mode (if selected) on iOS and Android while playing sound notifications, but only for my app. This means that I might want to:

  • Get current volume of device and store it
  • Get current mode of device and store it
  • Override volume
  • Play sound
  • Restore saved mode
  • Restore saved device volume

Is there a way to achieve this on Android and iOS?

Thanks

Disable UI of the whole app

$
0
0

What DisplayAlert does to Disable UI of the whole app?

Viewing all 77050 articles
Browse latest View live


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