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

System.TypeLoadException: 01000019

$
0
0

Hi List,
i create a Solution with Prism.
I run the solution in Windows 8 + Windows 10(UWP) including a Rasberry 3 an it works as far as i can see.
In Android, i get 'System.TypeLoadException: Could not resolve type with token 01000019'

Any idea?
Thanks
Peter


Toolbar with content page

$
0
0

Hello developers,

I am using the component https://github.com/thrive-now/BottomNavigationBarXF

I can't implement a toolbar in one contentpage of my bottomnavigation, example:

<ContentPage.ToolbarItems>
    <ToolbarItem Order="Secondary" Text="Cerrar sesión"  Activated="CerrarSesion"></ToolbarItem>
  </ContentPage.ToolbarItems>

Not showing toolbar...

any solution ?

Regards.

Xamarin.Firebase Not Compatible With Forms?

$
0
0

Trying to install Xamarin.Android and it appears that yet again Forms is restricting package dependencies:

Attempting to gather dependency information for package 'Xamarin.Firebase.Messaging.32.961.0' with respect to project 'IntelliDrive.Droid', targeting 'MonoAndroid,Version=v6.0'
Attempting to resolve dependencies for package 'Xamarin.Firebase.Messaging.32.961.0' with DependencyBehavior 'Lowest'
Unable to find a version of 'Xamarin.GooglePlayServices.Basement' that is compatible with 'Xamarin.Firebase.Common 32.961.0 constraint: Xamarin.GooglePlayServices.Basement (= 32.961.0)', 'Xamarin.Firebase.Iid 32.961.0 constraint: Xamarin.GooglePlayServices.Basement (= 32.961.0)', 'Xamarin.Firebase.Messaging 32.961.0 constraint: Xamarin.GooglePlayServices.Basement (= 32.961.0)', 'Xamarin.GooglePlayServices.Base 29.0.0.1 constraint: Xamarin.GooglePlayServices.Basement (= 29.0.0.1)', 'Xamarin.GooglePlayServices.Gcm 29.0.0.1 constraint: Xamarin.GooglePlayServices.Basement (= 29.0.0.1)', 'Xamarin.GooglePlayServices.Iid 32.961.0 constraint: Xamarin.GooglePlayServices.Basement (= 32.961.0)', 'Xamarin.GooglePlayServices.Maps 29.0.0.1 constraint: Xamarin.GooglePlayServices.Basement (= 29.0.0.1)', 'Xamarin.GooglePlayServices.Measurement 29.0.0.1 constraint: Xamarin.GooglePlayServices.Basement (= 29.0.0.1)', 'Xamarin.GooglePlayServices.Tasks 32.961.0 constraint: Xamarin.GooglePlayServices.Basement (= 32.961.0)'.

It requires a higher version of GooglePlayServices.Basement which can't be upgraded due to what Xamarin.Forms requires. Has anyone else managed to get Firebase working with XF? Or any word when there will be an update to it so we can work with newer technologies?

How to solve : Xamarin.Forms.Platform.Android.ViewRenderer`2.CreateNativeControl' not found

$
0
0

I'm creating a cross-platform app. When i click on the button to go to the location page where i render a map i encountered the next error:

Xamarin.Forms.Platform.Android.ViewRenderer`2.CreateNativeControl' not found.

Anyone have a solution?

ToolbarItem icon with BADGES could be possible (and with custom icon too)

$
0
0

Please help us to promote this ticket to prioritize fixing:
https://bugzilla.xamarin.com/show_bug.cgi?id=43569

Currently ToolbarItem hardcoded to use icons from resources. See the source code: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs

It's possible to draw custom icon (we prefer NGraphics, but native canvas is good to) but it's hard to use it. ToolbarItem can load icons ONLY from Resources.

Xamarin asked to promote this ticket for fast fixing :)

Please +1 to this thread if you have the same issue!

Master Detail with Tabbed Pages

$
0
0

Hi,

I am using INavigationService with the implementation of FormsNavigationPageService from XamarinUniversity.Interfaces library. It looks like the navigation stops working if I switch between navigation between parent child pages between Master Detail and Tabbed Pages. What am I missing here?.

Here is my initialization

       var navService = serviceLocator.Get<INavigationService>() as FormsNavigationPageService;
        var formsMessageVisualizerService = serviceLocator.Get<IMessageVisualizerService>() as FormsMessageVisualizerService;
        serviceLocator.Register<IMessageVisualizerService, FormsMessageVisualizerService>();
        serviceLocator.Register<ICurrentCampaignService, AzureCampaingService>();


        navService.RegisterPage(AppPages.MainPage, () => new MainPage());
        navService.RegisterPage(AppPages.ProfilePage, () => new ProfilePage());
        navService.RegisterPage(AppPages.HomePage, () => new RootPage());
        navService.RegisterPage(AppPages.ProfileRolePage, () => new ProfileRolePage());
        navService.RegisterPage(AppPages.CampaignPage, () => new MyCampaignPage());
        navService.RegisterPage(AppPages.CampaignDetailPage, () => new CampaignDetailPage());
        navService.RegisterPage(AppPages.AboutPage, () => new AboutPage());
        MainViewModel vm = new ViewModels.MainViewModel(navService,formsMessageVisualizerService,serviceLocator);
        MainPage = new NavigationPage(new MainPage() { BindingContext = vm });


       MainPage is the one that calls the master Detail page where the detail page is a tabbed page.

       App.Current.MainPage = new RootPage();

How do you create a Material MasterDetailPage?

$
0
0

Hi!

I'm creating an app using the MasterDetailPage. I was inspired from Hanselman and have used a bit of his code. Everything is going pretty good, but I have a hard time designing the NavigationDrawer in the MasterDetailPage on Android.

Now it looks like which you can see looks like Android 1.6 with the ugly orange color. It is supposed to look more like this

Is there anyone that has made something like this and can help me?

ObservableCollection with polymorphism doesnt refresh

$
0
0

Hello,
I have such snippet of code

    public static ObservableCollection<Income> Incomes => _incomeManager;
    public static ObservableCollection<Outcome> Outcomes => _outcomeManager;
    public static ObservableCollection<BaseActionModel> AllElements => GetAllElements();

    private static ObservableCollection<BaseActionModel> GetAllElements()
    {
        if (Incomes == null || Outcomes == null)
            return null;

        ObservableCollection<BaseActionModel> joinedCollection = new ObservableCollection<BaseActionModel>();
        foreach (var el in Incomes.Union<BaseActionModel>(Outcomes))
        {
            joinedCollection.Add(el);
        }

        return joinedCollection;
    }`

BaseActionModel is base type of Income and Outcome. Problem is that when im using AllElements as binding in xaml it doesnt update after adding element to any of Incomes or Outcomes. How could i "force" such refreshing?

Using Incomes or Outcomes as binding works just well.

Is this method of concatenation observable collections proper?

Thanks in advance


Xamarin Forms Permissions Plugin - Not working properly , Crashes

$
0
0

First , when i turn location permission off in App settings , i get the display alert that request permissions .

Bug 1 : Actually i get 2 of them , one after another

Bug 2 : I press Deny/Allow on both and the application crashes (System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.)

public async Task getLocation()
    {
        try
        {
                var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);
                if (status != PermissionStatus.Granted)
                {
                    var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Location });
                    status = results[Permission.Location];
                }

               if (status == PermissionStatus.Granted)
                {

                    locator.DesiredAccuracy = 50;

                    pos = await locator.GetPositionAsync(timeoutMilliseconds: 10000);

            }

        }catch (Exception E) { }
    }

Unhandled Exception -

System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.

on this line in mainActivity -

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }

FontAwesome Label: Here's how!

$
0
0

Here's how you'll use the new FontAwesome label (Any Graphic font will work, but FontAwesome is Awesome):

var coolLabel = new FontAwesomeIcon(FontAwesomeIcon.Icon.Gear)

Here's how to set it up.

Download the FontAwesome font and unzip it. Rename the ttf to FontAwesome.ttf. Note the Case of the name. Copy it to Android /Assets and mark as a BundleAsset. Copy to iOS /Resources and mark as BundleResource and "Copy Always". In iOS edit the info.plist and add this:

  <key>UIAppFonts</key>
  <string>FontAwesome.ttf</string>

Now that we have the font in our projects we need to tell Android, and ONLY Android how to get to the Font. Here's a renderer you can just drop in FontAwesomeIconRenderer.cs:

[assembly: ExportRenderer(typeof(FontAwesomeIcon), typeof(FontAwesomeIconRenderer))]

namespace AAA.Android.Renderers
{
    /// <summary>
    /// Add the FontAwesome.ttf to the Assets folder and mark as "Android Asset"
    /// </summary>
   public  class FontAwesomeIconRenderer: LabelRenderer
    {
       protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
       {
           base.OnElementChanged(e);
           if (e.OldElement == null)
           {
               //The ttf in /Assets is CaseSensitive, so name it FontAwesome.ttf
               Control.Typeface = Typeface.CreateFromAsset(Forms.Context.Assets, FontAwesomeIcon.Typeface + ".ttf");
           }
       }
    }
}

Here's the Label for your common UI project:

namespace AAA.Common.Views.Shared.FontAwesome
{
    public class FontAwesomeIcon : Label
    {
        //Must match the exact "Name" of the font which you can get by double clicking the TTF in Windows
        public const string Typeface = "FontAwesome";

        public FontAwesomeIcon(string fontAwesomeIcon=null)
        {
            FontFamily = Typeface;    //iOS is happy with this, Android needs a renderer to add ".ttf"
            Text = fontAwesomeIcon;
        }

        /// <summary>
        /// Get more icons from http://fortawesome.github.io/Font-Awesome/cheatsheet/
        /// Tip: Just copy and past the icon picture here to get the icon
        /// </summary>
        public static class Icon
        {
            public static readonly string Gear = "";
            public static readonly string Globe = "";
        }
    }
}

Why does the main PCL not build?

$
0
0

Hello all,

After adding string resources to my XF project, when trying to build, the following ERROR and ERROR MESSAGE occur:

 Error      The "ResolveLibraryProjectImports" task failed unexpectedly.
 System.IO.FileNotFoundException: Could not load assembly 'appName, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
 File name: 'appName.dll'
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.GetAssembly(String fileName)
    at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
    at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()    appName.Droid

I have tried to clean / rebuild the entire solution, clean / rebuild each project apart, with no avail. Tried also to Google around but nothing explicit came up. I also inspected the resx files for anything out the ordinary (special characters, accents in translations), I also inspected the XAML pages for any typos with no luck. Does anyone have an idea why it would behave like this?

Thank you!

List View Customization

$
0
0

Hello guys, how are I designing a screen .. in xamarin forms in xaml .. I was encountered with a design problem, I need a Listview to load the data collection of some profiles and I want to show them the same as the image I show .. .. the problem is that I can not find the way that my list view groups me two by two horizontally., Someone can lend a hand to solve this ... in advance thanks.

Can't access API Classes[IPushNotification] from xam.plugin.pushnotification in XF PCL project

$
0
0

I'm trying to use Push Notification plugin [https://github.com/rdelrosario/xamarin-plugins/tree/master/PushNotification] inside my Xamarin forms app.

I would like to keep notification receive part in shared code. So that I don't have to use any extra code on each platform. Which results in implementing IPushNotificationListener inside PCL project. But I don't have access to it inside the PCL project.

I don't have access to CrossPushNotification either.

So it means I have to create/initialize/listen push code in each platform?

How to bind button IsEnabled to checkbox in a listview

$
0
0

Hello, I have a page with a listview and a button to proceed. Inside the listview, there is a checkbox for every row. I would like to bind the button IsEnable property to the checkbox checked event when user checks the box. Could you please show me how to do that? Thanks in advance.

App.OnResume() not called on iOS

$
0
0

Hello guys,

I am having some trouble on the iOS App life cycle. I need to do some stuff inside the OnResume() method. My Android application calls it whenever it returns from the background. But when I am running my app on iOS, the OnResume() is never called when I bring my app to foreground.
It is a Location app and it keeps running in background until the user manually stops it.

This is how my code looks like:

public App ()
{
    InitApp();
}

private void InitApp()
{
    //Do stuff
}

protected override void OnStart ()
{
    System.Diagnostics.Debug.WriteLine (TAG + ".OnStart() called.");
}

protected override void OnSleep ()
{
    // Handle when your app sleeps
    System.Diagnostics.Debug.WriteLine (TAG + ".OnSleep() called.");
}

protected override void OnResume ()
{
    // Do some stuff when it returns from the background.

    // Handle when your app resumes
    System.Diagnostics.Debug.WriteLine (TAG + ".OnResume() called.");
}

How to confirm SMS send/receive in Xamarin Forms?

$
0
0

Hi,

What I need to do to confirm that the user sent the SMS successfully and when the message return from specific number, how can I count the received SMS details?

Any examples?

-IKK

How do I define a StaticResource of type Thickness?

$
0
0

I am trying to define a StaticResource in an application-level ResourceDictionary, and I am having trouble with the following markup:

      <Thickness x:Key="RelativeLayoutPadding">
        <Setter Property="Top" Value="15" />
        <Setter Property="Bottom" Value="15" />
        <Setter Property="Left" Value="15" />
        <Setter Property="Right" Value="15" />
      </Thickness>

I know the ResourceDictionary works, because it works with other types that I am setting, such as Doubles. However, for this markup, I get the error message that the property "Top" cannot be resolved (with a XamlParse exception). I originally thought this might be because the Thickness structure may not have public static properties for its Top, Bottom, Left, and Right Doubles. However, I have seen sample code for LayoutOptions having its Alignment property defined as a StaticResource and it is unclear from the documentation as to whether or not either the Alignment property or the Top, Bottom, Left, and Right properties are static. All, however, are clearly public, so I don't understand why the Setter class should have any issue in setting these properties. Please provide assistance.

Thanks,
Jordan

How do i bind database to a list

$
0
0

Hi, sorry im really new to this so sorry for being stupid. I have a database and i want to bind it to a list view with cells with the text and detail but i cant get it to work.

`public class TodoItem
{

    [PrimaryKey, AutoIncrement]
    public int ID { get; set; }

    public string Time { get; set;}

    public string Event { get; set; }

    public decimal ActTime { get; set;}

    public DateTime Swam { get; set; }

    public override string ToString()
    {
        return string.Format("{0} | {1} ", Time, Swam);
    }
}

}`

there is the code for the database.

Error installing MvvmCross.Forms.Presenter

$
0
0

I'm not able to install MvvmCross.Forms.Presenter in Xamarin Forms project.

I'm getting following error:

Error       Could not install package 'MvvmCross.Forms.Presenter 4.4.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.            0

My selected profile is:

Which targets should I choose to make it compatible?

Xamarin Forms 2.3.3.180

How can I bind MVVM command in Bindable Picker?

$
0
0

i want bind my mvvm command on bindable picker control while selected index changed for reason that i want bind other bindable picker in same content page.

any one can help me how can i achieve that scenario??, is it possible or not ??

how can i use b:EventHandlerBehavior ??

i am using this bindable picker control

Viewing all 91519 articles
Browse latest View live