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

Binding Context vs ItemsSource for ListView in Xamarin Forms

$
0
0

I am developing a Xamarin forms App, in which I have a class which I instantiate and give the value to the BindingContext. The issue is the listview does not show up with the values.

However, if I use the listview XAML reference name in the code behind and assign the list of the class to listview's ItemsSource property it works.

e.g. This is the C# code

public MainPage()
{
InitializeComponent();

        vm = new MainPageViewModel();            

        listview.ItemsSource = vm.People;                  
    }

public class MainPageViewModel
{
public ObservableCollection People = new ObservableCollection();

    public MainPageViewModel()
    {
        for(int i = 0; i <= 5; i++)
        {
            Person person = new Person();
            person.FirstName = "Sidd " + i.ToString();
            person.LastName = "Mehta" + i.ToString();
            People.Add(person);
        }
    }

}

public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
This is my XAML:


<ListView.ItemTemplate>



</ListView.ItemTemplate>

The above code shows the list view.

But if I use it with binding context, like the following:

XAML Code:


<ListView.ItemTemplate>



</ListView.ItemTemplate>

and C# code:

public MainPage()
{
InitializeComponent();

        vm = new MainPageViewModel();
        BindingContext = vm;                 
    }

This fails.

Any reason or help for this?. I have installed latest community edition of VS 2017, so everything is latest.

Thanks In Advance.


Cannot resolve Assembly or Windows Metadata file 'Shared.dll'

$
0
0

I am working on a xamarin forms application which targets android and ios. the app works fine when running both android and ios, but i also wanted to add support for UWP. I added a new project which targets windows and i have added all the packages, dependencies and reference to the core project and all that was required, but i keep getting this error when i try to run the app.

Cannot resolve Assembly or Windows Metadata file 'Shared.dll'

and

Type universe cannot resolve assembly: Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.

I have no idea why i am getting this error, so if anyone has any information about this, it would be greatly appreciated.

Thanks

How to navigate back to the MainPage? (PushAsync is not supported globally on Android... error)

$
0
0

Hi. In the Android Emulator (Nexus 5 image based, API 27) I got this error message:
PushAsync is not supported globally on Android, please use a NavigationPage.

If I know the following is the correct code.

My Code is the following:

public partial class CartPage : ContentPage
    {
        public CartPage()
        {
            InitializeComponent();
            CancelButton.Clicked += CancelButton_Clicked;
            FinischButton.Clicked += PayButton_Clicked;
        }

        async private void FinischButton_Clicked(object sender, EventArgs e)
        {
            Cart.FinshOrder();
            await Navigation.PushAsync(new NavigationPage(new MainPage()));
        }

        async private void CancelButton_Clicked(object sender, EventArgs e)
        {
            Cart.RemoveItems();
            await Navigation.PushAsync(new NavigationPage(new MainPage()));
        }
    }

I want that if the user click on the Cancel or Pay button then I want to navigate him back to the MainPage.

In Xamarin forms project uwp app does not debug throws error: The application cannot be started

$
0
0

I am building xamarin forms app in that i am not able to debug the uwp app it just throws below error while starting to debug uwp app

Activation for XXXXX_q60vbcv8e4n0m!App failed. Error code: The application cannot be started. Try reinstalling the application to fix the problem.. Activation phase: Deployment,

what is the cause of the error please help to fix it ?

Content Page Life Cycle

$
0
0

When setting the root page in the App.cs, Example: "MainPage = new ContentPage();" If i then do some navigation by setting the root page again to a new page : "MainPage = new NewContentPage();" Does the previous page stay open in the background? Do I have to manually close all references or does it get taken care of behind the scenes when setting a new root?

Thank you in advance !

Error using Xamarin Essentials' Geocoding

$
0
0

Hi,

I am trying to use the new Xamarin Essentials Geocoding from this doc:

https://docs.microsoft.com/en-us/xamarin/essentials/geocoding?context=xamarin%2Fxamarin-forms&tabs=android

The code looks like this:

var location = await Geolocation.GetLocationAsync();

latitude = location.Latitude;
longitude = location.Longitude;

var placemarks = await Geocoding.GetPlacemarksAsync(latitude, longitude);
var placemark = placemarks?.FirstOrDefault();

await DisplayAlert("latitude", Convert.ToString(latitude), "Ok");
await DisplayAlert("longitude", Convert.ToString(longitude), "Ok");
await DisplayAlert("country", placemark.CountryCode, "Ok");

but I am getting this error:

**Error CS1061: 'IEnumerable' does not contain a definition for 'FirstOrDefault' and no extension method 'FirstOrDefault' accepting a first argument of type 'IEnumerable' could be found (are you missing a using directive or an assembly reference?) (CS1061)
**

Thanks,
Jassim

Xamarin.Forms WebView while scrolling freezes content (CSS, HTML) progress

$
0
0

Hi guys, it's me again.

I've built a Xamarin.Forms application which contains a full width/height WebView inside. Now, when I start scrolling on that WebView, it freezes my HTML page in the WebView.

For example, any progressbar which is loading on the HTML content of the WebView stops loading / progressing while I'm scrolling. When I finish scrolling, it still doesn't continue the progressbar until I tap inside the WebView on the content, suddenly it starts loading again to the next time I start scrolling.

It's like the WebView freezes while scrolling and waiting for any gestures (tap) to continue the HTML / JS workflow. Or it stops rendering while scrolling, I don't know!

How can I prevent this? I'd like to scroll and let the WebView content work asynchronously farther.

I've tried it only on android devices so far. About iOS there are no informations right now, will test it later. But I guess it's a android problem with their WebView.

I appreciate any answer on this!

Thanks a lot,
Dominik.

Set the Row height to Auto for RowDefinitionCollection in Xamarin

$
0
0

There are 50 rows in my Grid Layout so to set the row height of each row I have to add <RowDefinition Height="Auto"/> 50 times so is there any way to reduce the redundancy. I have tried to use <RowDefinitionCollection/> but for this the default height is "*" .


System.NullReferenceException with Xamarin.Forms.Maps (Android)

$
0
0

Hi

As soon as I attempt to include a map in my XAML with:

<maps:Map x:Name="MyMap" IsShowingUser="false" MapType="Street"/>

I get an exception: System.NullReferenceException. This is using latest Xamarin.forms and Forms.Maps as of 20th June. I have followed the instructions at: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/map I don't yet have an API key so I am expecting a grey box as detailed on this page, but not expecting a crash. The init code is called in my Xamarin.Android mainactivity.create thus:

Xamarin.Forms.Forms.Init(this, bundle);
Xamarin.FormsMaps.Init(this, bundle);

All the stated permissions have been obtained.

I have also placed the maps code in my code-behind with exactly the same result. Device Monitor shows me nothing of note, the error text would appear to show the device unable to locate the library required for google maps. Google maps runs just fine on the device.

Device is Samsung S7 with Android 7.1

Anyone got any idea's - none of the solutions to this issue elsewhere fixes my issue (these are mostly related to running on emulators - I am using a physical device).

06-20 13:35:20.341 W/System  ( 6232): ClassLoader referenced unknown path: 
06-20 13:35:20.431 W/System  ( 6232): ClassLoader referenced unknown path: /data/user_de/0/com.google.android.gms/app_chimera/m/00000030/n/armeabi
06-20 13:35:20.486 I/Google Maps Android API( 6232): Google Play services client version: 10298000
06-20 13:35:20.498 I/Google Maps Android API( 6232): Google Play services package version: 12685025
Unhandled Exception:

System.NullReferenceException: Object reference not set to an instance of an object.

Nigel

Using singleton pattern for creating SQLiteConnection in Xamarin.forms is not working for iOS.

$
0
0

I've created xamarin.forms app.
In portable project, I'm creating SQLiteConnection using singleton pattern and I'm using this connection in platform specific projects.
On android it works perfectly fine, but on iOS, the app fails with exception "SQLite.SQLiteException: Could not open database file".

CustomEntryRenderer errors

$
0
0

I'm trying to create a custom renderer for an entry control, and have followed this link: https://forums.xamarin.com/discussion/96991/how-to-remove-underline-in-entry

However, when I try to test the application, I get the following errors:

All of these errors are in the Android CustomEntryRenderer.cs file. What do I need to do to resolve them?

My Android CER.cs file

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

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

[assembly: ExportRenderer(typeof(CustomEntry), typeof(CustomEntryRenderer))]
namespace XPlatform.Droid
{
    public class CustomEntryRenderer : EntryRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                GradientDrawable gd = new GradientDrawable();
                gd.SetColor(global::Android.Graphics.Color.Transparent);
                this.Control.SetBackgroundDrawable(gd);
                this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
                Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.White));
            }
        }
    }
}

Mono error while building to iOS Ad-hoc

$
0
0

Getting this error after last VS 2017 Xamarin & Mac updates.

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: removing global symbols from a final linked no longer supported. Use -exported_symbols_list at link time when building: /Users/RSC/Library/Caches/Xamarin/mtbs/builds/Project.iOS/95fb309ddc8ee39d737463f2f0914b29/bin/iPhone/Ad-Hoc/Project.iOS.app/Project.iOS
4>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(1785,3): error : /Users/RSC/Library/Caches/Xamarin/mtbs/builds/Project.iOS/95fb309ddc8ee39d737463f2f0914b29/bin/iPhone/Ad-Hoc/Project.iOS.app/Frameworks/Mono.framework/Mono: errSecInternalComponent

iOS Bundle Signing tab shows an error

$
0
0

When clicking on ios project properties iOS Bundle Signing tab shows an error "Value cannot be null. Parameter name: source ".
When clicking second time on this tab there is a different error "An error occurred trying to load the page. Unable to create the designer. File is already opened in an incompatible editor."
When trying to connect to Mac Build Host, the connection succeeds, but seconds after Visual Studio just crashes.
Visual Studio and Xamarin is up to date on both Windows and Mac.
Previously worked fine with developer provisioning, the problem appeared when tried to configure for Ad-Hoc provisioning.
Please, help me to figure out.

Icon don't work in BottomTabbedPage in Xamarin Forms 3.1 pre4

$
0
0

My icons worked when I had the tabbed page in the top , now I update them and a put them in the bottom and icon does't show ?

Xamarin.Forms MessagingCenter to update Pages BindingContext and PopAsync

$
0
0

Hi Guys,

i have the following situation:

      private async void UpdateKundenDatenInOverviewPage(KundenDatenPageModel e)
                        {
                            initializerModel.KundenDaten = e;
                
                            BindingContext = initializerModel;
                
                            await Navigation.PopAsync();
                        }

This Method gets invoked by a Message my Page subscribes from. The initializerModel is a class member and gets initialized once in the constructor of the page with default values. After the message was sent i want to update the KundenDaten Property of the initializerModel in order to bind the new data to the page again. But it wont work.

            private async void UpdateKundenDatenInOverviewPage(KundenDatenPageModel e)
            {
                OverviewPageModel initializerModel = new OverviewPageModel();
                initializerModel .KundenDaten = e;
                initializerModel .FahrzeugZustand = fahrzeugZustand;

                BindingContext = initializerModel;

                await Navigation.PopAsync();
            }

This code works. So if i create a new instance of initializerModel (in this case its a OverviewPageModel) and set it as the pages BindingContext the data will appear after i pop the page the message was sent from from the navigationstack.

Can u guys help me?
Thank you in advance, Gelatto


System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocatio

$
0
0

Hi I got this error when i navigate to a page from a list view in xamarin forms . I can't find the actual problem can any one help he to find where the problem is happening from this report . am using MVVMLight
[0:] Error NavigateTo BenWorkTasksPage. Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid. at Xamarin.Forms.Label.FontStructPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00000] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle) [0x00000] in <filename unknown>:0 at Xamarin.Forms.Setter.Apply (Xamarin.Forms.BindableObject target, Boolean fromStyle) [0x000a4] in <filename unknown>:0 at Xamarin.Forms.Style.ApplyCore (Xamarin.Forms.BindableObject bindable, Xamarin.Forms.Style basedOn) [0x0001e] in <filename unknown>:0 at Xamarin.Forms.Style.Xamarin.Forms.IStyle.Apply (Xamarin.Forms.BindableObject bindable) [0x0003e] in <filename unknown>:0 at Xamarin.Forms.VisualElement+MergedStyle.SetStyle (IStyle implicitStyle, IStyle classStyle, IStyle style) [0x00111] in <filename unknown>:0 at Xamarin.Forms.VisualElement+MergedStyle.set_Style (IStyle value) [0x0000d] in <filename unknown>:0 at Xamarin.Forms.VisualElement+<>c.<.cctor>b__211_6 (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x00000] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in <filename unknown>:0 at IWSM.XamarinApp.Views.BenWorkTasksPage.InitializeComponent () [0x0af0c] in <filename unknown>:0 at IWSM.XamarinApp.Views.BenWorkTasksPage..ctor (IWSM.Shared.DataModels.WorkTaskDataModel wtdm) [0x00008] in D:\Shamnad_TFS_Workspace\IWSM.XamarinApp\IWSM.XamarinApp\IWSM.XamarinApp\Views\BenWorking\BenWorkTasksPage.xaml.cs:31 at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644 --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:650 at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00089] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:635 at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:663 at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62 at IWSM.XamarinApp.Common.NavigationService+<NavigateTo>d__15.MoveNext () [0x00173] in D:\Shamnad_TFS_Workspace\IWSM.XamarinApp\IWSM.XamarinApp\IWSM.XamarinApp\Common\NavigationService.cs:115 [0:] OnItemTapped: IWSM.Shared.DataModels.WorkTaskDataModel [0:] Error NavigateTo BenWorkTasksPage. Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid. at Xamarin.Forms.Label.FontStructPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00000] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle) [0x00000] in <filename unknown>:0 at Xamarin.Forms.Setter.Apply (Xamarin.Forms.BindableObject target, Boolean fromStyle) [0x000a4] in <filename unknown>:0 at Xamarin.Forms.Style.ApplyCore (Xamarin.Forms.BindableObject bindable, Xamarin.Forms.Style basedOn) [0x0001e] in <filename unknown>:0 at Xamarin.Forms.Style.Xamarin.Forms.IStyle.Apply (Xamarin.Forms.BindableObject bindable) [0x0003e] in <filename unknown>:0 at Xamarin.Forms.VisualElement+MergedStyle.SetStyle (IStyle implicitStyle, IStyle classStyle, IStyle style) [0x00111] in <filename unknown>:0 at Xamarin.Forms.VisualElement+MergedStyle.set_Style (IStyle value) [0x0000d] in <filename unknown>:0 at Xamarin.Forms.VisualElement+<>c.<.cctor>b__211_6 (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x00000] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) [0x0005f] in <filename unknown>:0 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in <filename unknown>:0 at IWSM.XamarinApp.Views.BenWorkTasksPage.InitializeComponent () [0x0af0c] in <filename unknown>:0 at IWSM.XamarinApp.Views.BenWorkTasksPage..ctor (IWSM.Shared.DataModels.WorkTaskDataModel wtdm) [0x00008] in D:\Shamnad_TFS_Workspace\IWSM.XamarinApp\IWSM.XamarinApp\IWSM.XamarinApp\Views\BenWorking\BenWorkTasksPage.xaml.cs:31 at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644 --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:650 at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00089] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:635 at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:663 at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in /Users/builder/data/lanes/3339/39ebb778/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62 at IWSM.XamarinApp.Common.NavigationService+<NavigateTo>d__15.MoveNext () [0x00173] in D:\Shamnad_TFS_Workspace\IWSM.XamarinApp\IWSM.XamarinApp\IWSM.XamarinApp\Common\NavigationService.cs:115

Best way to pass data from code-behind to view model when using strict MVVM

$
0
0

Scenario:
I'm using a barcode scanner API in my view which seems to require me to hook up an event in the code-behind file as the only way to get the scanned barcode. When the barcode is scanned I want to pass the data on to the view model but since I want to follow the MVVM pattern I don't want a reference to the view model from my code-behind.

Right now I solved it by using the built in MessagingCenter.
Since the subview is showing within another view, there is no navigation taking place where I can pass on data from one vm to another.

Question:
Is MessagingCenter the best solution for this?

Sub question:
What is the best way to pass data between two view models for views showing at the same time (no navigation occurs)? I'm using MessagingCenter for this too right now.

Hope someone can help me debug this. (System.ArgumentNullException)

$
0
0

I posted this on Xamarin.IOS forums. Posting again here in case anyone can help.

I have an application that runs in UWP, Android & iOS.
I have added a custom font to the application and included it in info.plist.
The app runs fine in UWP and Android.
When I run the application in iOS, I get the following error in AppDelegate.cs when calling base.FinishedLaunching
Exception:

System.ArgumentNullException: Value cannot be null.
Parameter name: descriptor

The app still launches, and I can see the fonts that are being used.
If all I do is edit the info.plist to remove the font reference, or just misspell it so that it is not found, then the exception is not thrown. The app still runs but there a "?"s where my font symbols should have been.

I have not been able to reproduce this in a skeletal application, so the problem must be somewhere in my code.
I cannot get VS2017 to break on ArgumentNullException (It basically ignores the exception settings when running an iOS emulator)

Is there a log somewhere that would contain the exception details?
Is there an option to emit a trace?
Any help is appreciated.

Absolute Layout with Image+StackLayout width fill

$
0
0

Greetings,

How can one set an image width to fill inside an AbsoluteLayout?
Aspect and HorizontalOptions don't seem to work.

I need to draw an semi-transparent StackLayout over this image and have them both filling the screen width.

Thank you

Drawing on Image using SkaiSharp too slow.

$
0
0

Hi,

In developing an app for the user to take a picture and draw on the image, is all good so far using the media plugin to get image and skiasharp to draw on the image but drawing on the image is very slow, the image file size is about a 1MB .

this is the method to load the image and fingerpaint (from Demo)

 void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
        {

            SKCanvas canvas = args.Surface.Canvas;
            canvas.Clear();

            SKBitmap resourceBitmap = SKBitmap.Decode(MediaFile.ContentAsBytes);
            canvas.DrawBitmap(resourceBitmap, 0, 0);

            foreach (FingerPaintPolyline polyline in completedPolylines)
            {
                paint.Color = polyline.StrokeColor.ToSKColor();
                paint.StrokeWidth = polyline.StrokeWidth;
                canvas.DrawPath(polyline.Path, paint);
            }

            foreach (FingerPaintPolyline polyline in inProgressPolylines.Values)
            {
                paint.Color = polyline.StrokeColor.ToSKColor();
                paint.StrokeWidth = polyline.StrokeWidth;
                canvas.DrawPath(polyline.Path, paint);
            }
        }

I think the problem is that the view is refreshing for each stroke and I gets slower and slower .

How can improve this ?

thanks

Hernando

Viewing all 89864 articles
Browse latest View live


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