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

Field changed to null???

$
0
0

I was building a demo for another question on here when i came across another lovely problem with the Name field of a Model object in my List changing to null when you press a button to fire a command.

The first time you press either button, it works fine. But when you go back and select the other button, it changes the Name field to null.

The code below will explain it more:

ViewModel:

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.ComponentModel;
    using System.Linq;
    using System.Text;
    using System.Windows.Input;
    using Xamarin.Forms;

    namespace BindingExample
    {
      public class MainViewModel : INotifyPropertyChanged
      {
        public event PropertyChangedEventHandler PropertyChanged;
        void OnPropertyChanged(string propertyName)
        {
          if (PropertyChanged != null)
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        private ObservableCollection<Model> _listOfModels { get; set; }
        public ObservableCollection<Model> ListOfModels
        {
          get { return _listOfModels; }
          set
          {
            if (_listOfModels != value)
            {
              _listOfModels = value;
            }
          }
        }

        private Model _selectedModel;
        public Model SelectedModel
        {
          get { return _selectedModel; }
          set
          {
            _selectedModel = value;
            OnPropertyChanged("SelectedModel");
          }
        }

        private bool _isPickerSelected = false;
        public bool IsPickerSelected
        {
          get { return _isPickerSelected; }
          set
          {
            _isPickerSelected = value;
            OnPropertyChanged("IsPickerSelected");
          }
        }

        private bool _isListSelected = false;
        public bool IsListSelected
        {
          get { return _isListSelected; }
          set
          {
            _isListSelected = value;
            OnPropertyChanged("IsListSelected");
          }
        }

        public ICommand OnPickerSelectedCommand { get; }
        public ICommand OnListSelectedCommand { get; }

        public MainViewModel()
        {
          OnPickerSelectedCommand = new Command(OnPickerSelectedCommandExecuted);
          OnListSelectedCommand = new Command(OnListSelectedCommandExecuted);

          ListOfModels = new ObservableCollection<Model>();

          ListOfModels.Add(new Model
          {
            Name = "Picker",
            Numbers = new List<Number>(){
              new Number {Name = "One", Value = 1 },
              new Number {Name = "Two", Value = 2 },
              new Number {Name = "Three", Value = 3 },},
            Enabled = true
          });
          ListOfModels.Add(new Model
          {
            Name = "List",
            Numbers = new List<Number>(){
              new Number {Name = "One", Value = 1 },
              new Number {Name = "Two", Value = 2 },
              new Number {Name = "Three", Value = 3 },},
            Enabled = false
          });
        }

        private void OnPickerSelectedCommandExecuted()
        {
          SelectedModel = ListOfModels.Where(e => e.Name == "Picker").First();
          IsPickerSelected = true;
          IsListSelected = false;
        }

        private void OnListSelectedCommandExecuted()
        {
          SelectedModel = ListOfModels.Where(e => e.Name == "List").First();
          IsPickerSelected = false;
          IsListSelected = true;
        }
      }

      public class Model
      {
        public string Name { get; set; }
        public List<Number> Numbers { get; set; }
        public bool Enabled { get; set; }
      }

      public class Number
      {
        public string Name { get; set; }
        public int Value { get; set; }
      }
    }

xaml:

    <?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="BindingExample.MainPage">
      <StackLayout>
        <StackLayout Orientation="Horizontal">
          <Label Text="Models:"/>
          <Button Text="Picker" Command="{Binding OnPickerSelectedCommand}"/>
          <Button Text="List" Command="{Binding OnListSelectedCommand}"/>
        </StackLayout>
        <StackLayout IsVisible="{Binding IsPickerSelected}" Orientation="Vertical">
          <Label Text="Select a Value:" />
          <Picker
            Title="picker_select"
            ItemsSource="{Binding Numbers}" BindingContext="{Binding SelectedModel}"
            ItemDisplayBinding="{Binding Name}"
            SelectedItem="{Binding Name}"/>
        </StackLayout>
        <StackLayout IsVisible="{Binding IsListSelected}" Orientation="Vertical">
          <Label Text="Select Options:"/>
          <ListView ItemsSource="{Binding Numbers}" BindingContext="{Binding SelectedModel}"
                    HasUnevenRows="True"
                    SeparatorColor="Gray"
                    VerticalOptions="FillAndExpand"
                    HorizontalOptions="FillAndExpand">
            <ListView.ItemTemplate>
              <DataTemplate>
                <ViewCell>
                  <StackLayout HorizontalOptions="FillAndExpand" Orientation="Horizontal">
                    <Label Text="{Binding Name}" TextColor="Black" FontSize="Small" 
                                 HorizontalOptions="StartAndExpand"/>
                    <Switch HorizontalOptions="End"/>
                  </StackLayout>
                </ViewCell>
              </DataTemplate>
            </ListView.ItemTemplate>
          </ListView>
        </StackLayout>
      </StackLayout>
    </ContentPage>

code behind:

    using Xamarin.Forms;

    namespace BindingExample
    {
      public partial class MainPage : ContentPage
      {
        public MainPage()
        {
          InitializeComponent();
          BindingContext = new MainViewModel();
        }
      }
    }



InitializeComponent does not exist in the current context error

$
0
0

Hi,

The error CS0103 (The name 'InitializeComponent' does not exist in the current context) has started appearing after doing a build of our Xamarin Forms solution. The build, however, appears to have succeeded in spite of this error message?

This started happening after adding the first XAML ContentPage to the PCL project. If I remove the XAML ContentPage then the error disappears.

I've tried installing the latest Alpha channel update on both my Windows (Visual Studio) machine and my Mac build host but it hasn't made any difference.

Please advise ASAP as we would like to use XAML for our ContentPages but may have to revert to using C# code to build the UI if the XAML approach is not viable.

Regards,
Andy

How can I customize the refreshing icon for a Pull to Refresh Listview?

$
0
0

I would like to modify the existing refreshing animation for the Pull to Refresh for a Listview.

I've created a Listview with the following properties:

RefreshCommand="{Binding LoadItemsCommand}"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsRefreshing, Mode=OneWay}"
CachingStrategy="RecycleElement"

And the pull to refresh action works like I want it to, but the animation used is the standard Android and iOS animation. I would like to customize this by adding some text, changing the position of the loading icon and changing the color schemes.

I've achieved the perfect layout by placing a grid over my listview and binding the IsVisible to the same IsRefreshing, but it only shows after the refreshing command has started (which makes sense of course...) and I would like this grid to slide down when starting the pull down, showing while refreshing and dissappearing when the refreshing is done.

Any help is much appreciated!

I'm struggling to get databinding to work

$
0
0

So I am pulling from a table called "Person" in a SQLite database. This table has several properties including the PersonId and PersonName. There are many "people" in this table. I am trying to pull a specific PersonName and populate a Button's text with it. What is coming out is just a blank button with no text. Here is what I have in xaml:

<ContentPage.Content>
    <ListView x:Name="peopleList">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell Height="30">
                    <StackLayout Padding="5">
                        <Button Text="{Binding People[0].PersonName}" />
                    </StackLayout>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</ContentPage.Content>

Here is the code behind:

public List<Person> People { get; set; }

    protected override void OnAppearing()
{
    PopulatePeople();

}



    public async void PopulatePeople()
    {
        List<Person> People = await App.PeopleRepo.GetAllPeople();
            peopleList.ItemsSource = People; 
     }

Here is the GetAllPeople() method defined in the PeopleRepository class:

    public SQLiteAsyncConnection conn;
    public PeopleRepository(string db)
    {
        conn = new SQLiteAsyncConnection(db);
        conn.CreateTableAsync<Person>().Wait();
    }

        public async Task<List<Person>> GetAllPeople()
    {
        try
        {
             return await conn.Table<Person>().ToListAsync();
        }
        catch (Exception ex)
        {
            Status = string.Format("Failed to retrieve data. {0}", ex.Message);
        }

        return new List<Person>();
    }

I just can't get this working. I have struggled some with my understanding of databinding and have researched it a ton and I feel that this should work. What am I missing?

Xamrin Forms CarouselView with GridLayout Collection?

$
0
0

Given a collection of items - how would one implement a grid layout like so:

(from https://github.com/pauldipietro/CollectionViewSample)
... but instead of the list scrolling vertically down - create a new carousel page to scroll horizontally?

Will the new XF4 controls cater for this scenario?

Disable Compass Calibration Screen in iOS

$
0
0

I'm trying to disable the compass calibration screen from appearing in iOS within my Xamarin.Forms application. I've found the following Xamarin.iOS API method needed to disable the screen programatically:

https://developer.xamarin.com/api/member/MonoMac.CoreLocation.CLLocationManagerDelegate.ShouldDisplayHeadingCalibration/

I am having trouble figuring out exactly how to call it from my Xamarin Forms application.

Here is a C# code snippet of how I'm calling it from a view model in my Xamarin.Forms MVVM application:

#if __IOS__
            var locationManager = new CoreLocation.CLLocationManager();
            locationManager.RequestWhenInUseAuthorization(); // only when in foreground
            //locationManager.RequestAlwaysAuthorization();// always
            locationManager.ShouldDisplayHeadingCalibration += (CoreLocation.CLLocationManager manager) => {return false;};
#endif

Unfortunately this coding solution doesn't work as I'm still seeing the compass calibration screen within my application.

I'm assuming I need to get a reference to the existing core location manager and assign this delegate override there instead of instantiating a new one on every request to load my view model but can't find how to do that in any of the documentation or coding examples.

Any help is greatly appreciated.

Bind keyboard type in XAML?

$
0
0

On one Page, need to display either the standard or numeric keyboard, depending on a property of our PageModel.
We were hoping that the following would work.

XAML:

<Entry x:Name="AnswerEntry" Grid.Row="2" Style="{StaticResource entryStyle}" HorizontalTextAlignment="Start" Keyboard="{Binding KeyboardType}" Text="{Binding AnswerValue}" />

PageModel:

                switch (this.PageParams.Question.ChaType)
                {
                    // N = Integer numeric
                    case "N":
                    // V = Decimal numeric
                    case "V":
                        this.KeyboardType = Keyboard.Numeric;
                        break;
                    default:
                        this.KeyboardType = Keyboard.Text;
                        break;
                }

However, I'm only getting a default keyboard.

I'm implementing INotifyPropertyChanged etc. - other properties/controls are working.

Do I have to bind differently for Keyboard? Is it bindable?

Spam is getting out of hand

$
0
0

Title basically says everything. The spam from whoever these guys are is getting seriously out of hand. It is nearly impossible to use the forum with the amount of "shitposting" going on. Can't the admins do anything against that. It's really grinding my gears....


C# Xamarin How to update a static string in a label

$
0
0

i want to update a label with a static string. Thats my actual Code

public partial class MainPage : INotifyPropertyChanged
{
private static String _uploadstring;
///


/// A static property which you'd like to bind to
///

public static String Uploadstring
{
get
{
return _uploadstring;
}

    set
    {
        _uploadstring = value;

    }
}

and i want call it with

    Device.BeginInvokeOnMainThread(async () =>
    {
        Uploadstring = "TEEEEEEST";
    });

here is my XAML Binding

   <Label Text="{Binding Source={x:Staticlocal:MainPage.UploadString}}" x:Name="ttts"  TextColor="Red" TranslationY="50" HeightRequest="30" FontSize="26" HorizontalOptions="Center"/>

If i set i breakpoint i see that the Uploadstring is updated in my XAML. But he dont display it because he dosent update the text. How can i solve my problem?

Error when I try open app using Entity Framework

$
0
0

Hi I have an app on the test channel of the play store, it was work fine, but I solved use Entity Framework, when I released a version the app stoped to work, on Visual Studio run normally but if I install using apk file and try open it not work.
When I install app using abd shell and I get the follow stacktrace:

:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=br.com.arasolution.trackermobile/md5fe955b898135a8fb7f26617b645b333c.MainActivity;end
    // Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=br.com.arasolution.trackermobile/md5fe955b898135a8fb7f26617b645b333c.MainActivity } in package br.com.arasolution.trackermobile
    // Rejecting start of Intent { cmp=com.samsung.android.app.galaxyfinder/.GalaxyFinderActivity } in package com.samsung.android.app.galaxyfinder
:Sending Touch (ACTION_DOWN): 0:(62.0,1345.0)
    // Injection Failed
    // Injection Failed
:Sending Touch (ACTION_UP): 0:(63.430508,1346.4381)
    // Injection Failed
:Sending Touch (ACTION_DOWN): 0:(439.0,755.0)
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
    // Injection Failed
:Sending Touch (ACTION_UP): 0:(552.60547,713.5607)
    // Injection Failed
    // Rejecting start of Intent { act=android.content.pm.action.REQUEST_PERMISSIONS pkg=com.google.android.packageinstaller cmp=com.google.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity } in package com.google.android.packageinstaller
// CRASH: br.com.arasolution.trackermobile (pid 25057)
// Short Msg: android.runtime.JavaProxyThrowable
// Long Msg: android.runtime.JavaProxyThrowable: System.ArgumentException: The method 'b[Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder`1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation],Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder`1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation]].c' is not a property accessor
Parameter name: propertyAccessor
  at System.Linq.Expressions.Expression.GetProperty (System.Reflection.MethodInfo mi, System.String paramName, System.Int32 index) [0x00088] in <ba85ba5122c3499483c4d8a7ac6f7e5a>:0
  at System.Linq.Expressions.Expression.Property (System.Linq.Expressions.Expression expression, System.Reflection.MethodInfo propertyAccessor) [0x00016] in <ba85ba5122c3499483c4d8a7ac6f7e5a>:0
  at TrackerMobile.Migracoes.Migrations.MigracaoInicial+<>c.a (Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.CreateTableBuilder`1[TColumns] A_0) [0x0002b] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
  at Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder.CreateTable[TColumns] (System.String name, System.Func`2[T,TResult] columns, System.String schema, System.Action`1[T] constraints) [0x000cb] in <69f795dffc844780bfcfff4ff8415a92>:0
  at TrackerMobile.Migracoes.Migrations.MigracaoInicial.Up (Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder migrationBuilder) [0x00000] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
  at Microsoft.EntityFrameworkCore.Migrations.Migration.BuildOperations (System.Action`1[T] buildAction) [0x0000c] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Migrations.Migration.<.ctor>b__4_1 () [0x0000e] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Internal.LazyRef`1[T].get_Value () [0x00008] in <adf771f92e754fe1bb85c5850cd0c16b>:0
  at Microsoft.EntityFrameworkCore.Migrations.Migration.get_UpOperations () [0x00000] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql (Microsoft.EntityFrameworkCore.Migrations.Migration migration) [0x00033] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator+<>c__DisplayClass13_2.<GetMigrationCommandLists>b__2 () [0x00026] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate (System.String targetMigration) [0x0007a] in <69f795dffc844780bfcfff4ff8415a92>:0
  at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate (Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade) [0x00010] in <69f795dffc844780bfcfff4ff8415a92>:0
  at TrackerMobile.DB.IAppDbContext..ctor (Microsoft.EntityFrameworkCore.DbContextOptions`1[TContext] options) [0x0007f] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
  at TrackerMobile.DB.AppDbContext..ctor (Microsoft.EntityFrameworkCore.DbContextOptions`1[TContext] options) [0x00000] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
  at TrackerMobile.Forms.ViewModels.LoginViewModel.d () [0x00026] in <616f42fbee9f4a8091394a539e521ece>:0
  at TrackerMobile.Forms.ViewModels.LoginViewModel.OnAppearing () [0x00000] in <616f42fbee9f4a8091394a539e521ece>:0
  at Prism.Behaviors.PageLifeCycleAwareBehavior+<>c.<OnAppearing>b__2_0 (Prism.AppModel.IPageLifecycleAware aware) [0x00000] in <67be6ca629f141368fde5ee65f270d8b>:0
  at Prism.Common.PageUtilities.InvokeViewAndViewModelAction[T] (System.Object view, System.Action`1[T] action) [0x0003e] in <67be6ca629f141368fde5ee65f270d8b>:0
  at Prism.Behaviors.PageLifeCycleAwareBehavior.OnAppearing (System.Object sender, System.EventArgs e) [0x00006] in <67be6ca629f141368fde5ee65f270d8b>:0
  at Xamarin.Forms.Page.SendAppearing () [0x00034] in <a9131f61340149fcbb08ad43ae808046>:0
  at Xamarin.Forms.Page.SendAppearing () [0x00056] in <a9131f61340149fcbb08ad43ae808046>:0
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnAttachedToWindow () [0x0000c] in <e11d74a01fc148949d5e89708470f54c>:0
  at Android.Views.View.n_OnAttachedToWindow (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <2960acf2eeb24d88b5230e1e8afbdc2e>:0
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.34(intptr,intptr)
// Build Label: samsung/on7xelteub/on7xelte:8.1.0/M1AJQ/G610MUBS4CSB4:user/release-keys
// Build Changelist: G610MUBS4CSB4
// Build Time: 1550493190000
// android.runtime.JavaProxyThrowable: System.ArgumentException: The method 'b[Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder`1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation],Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder`1[Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation]].c' is not a property accessor
// Parameter name: propertyAccessor
//   at System.Linq.Expressions.Expression.GetProperty (System.Reflection.MethodInfo mi, System.String paramName, System.Int32 index) [0x00088] in <ba85ba5122c3499483c4d8a7ac6f7e5a>:0
//   at System.Linq.Expressions.Expression.Property (System.Linq.Expressions.Expression expression, System.Reflection.MethodInfo propertyAccessor) [0x00016] in <ba85ba5122c3499483c4d8a7ac6f7e5a>:0
//   at TrackerMobile.Migracoes.Migrations.MigracaoInicial+<>c.a (Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.CreateTableBuilder`1[TColumns] A_0) [0x0002b] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
//   at Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder.CreateTable[TColumns] (System.String name, System.Func`2[T,TResult] columns, System.String schema, System.Action`1[T] constraints) [0x000cb] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at TrackerMobile.Migracoes.Migrations.MigracaoInicial.Up (Microsoft.EntityFrameworkCore.Migrations.MigrationBuilder migrationBuilder) [0x00000] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Migration.BuildOperations (System.Action`1[T] buildAction) [0x0000c] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Migration.<.ctor>b__4_1 () [0x0000e] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Internal.LazyRef`1[T].get_Value () [0x00008] in <adf771f92e754fe1bb85c5850cd0c16b>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Migration.get_UpOperations () [0x00000] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateUpSql (Microsoft.EntityFrameworkCore.Migrations.Migration migration) [0x00033] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator+<>c__DisplayClass13_2.<GetMigrationCommandLists>b__2 () [0x00026] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate (System.String targetMigration) [0x0007a] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate (Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade) [0x00010] in <69f795dffc844780bfcfff4ff8415a92>:0
//   at TrackerMobile.DB.IAppDbContext..ctor (Microsoft.EntityFrameworkCore.DbContextOptions`1[TContext] options) [0x0007f] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
//   at TrackerMobile.DB.AppDbContext..ctor (Microsoft.EntityFrameworkCore.DbContextOptions`1[TContext] options) [0x00000] in <46f5c8519d4a4dc684a0a82b19d909d3>:0
//   at TrackerMobile.Forms.ViewModels.LoginViewModel.d () [0x00026] in <616f42fbee9f4a8091394a539e521ece>:0
//   at TrackerMobile.Forms.ViewModels.LoginViewModel.OnAppearing () [0x00000] in <616f42fbee9f4a8091394a539e521ece>:0
//   at Prism.Behaviors.PageLifeCycleAwareBehavior+<>c.<OnAppearing>b__2_0 (Prism.AppModel.IPageLifecycleAware aware) [0x00000] in <67be6ca629f141368fde5ee65f270d8b>:0
//   at Prism.Common.PageUtilities.InvokeViewAndViewModelAction[T] (System.Object view, System.Action`1[T] action) [0x0003e] in <67be6ca629f141368fde5ee65f270d8b>:0
//   at Prism.Behaviors.PageLifeCycleAwareBehavior.OnAppearing (System.Object sender, System.EventArgs e) [0x00006] in <67be6ca629f141368fde5ee65f270d8b>:0
//   at Xamarin.Forms.Page.SendAppearing () [0x00034] in <a9131f61340149fcbb08ad43ae808046>:0
//   at Xamarin.Forms.Page.SendAppearing () [0x00056] in <a9131f61340149fcbb08ad43ae808046>:0
//   at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnAttachedToWindow () [0x0000c] in <e11d74a01fc148949d5e89708470f54c>:0
//   at Android.Views.View.n_OnAttachedToWindow (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <2960acf2eeb24d88b5230e1e8afbdc2e>:0
//   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.34(intptr,intptr)
//      at md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer.n_onAttachedToWindow(Native Method)
//      at md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer.onAttachedToWindow(NavigationPageRenderer.java:49)
//      at android.view.View.dispatchAttachedToWindow(View.java:18728)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3534)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3541)
//      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2186)
//      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1863)
//      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8072)
//      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
//      at android.view.Choreographer.doCallbacks(Choreographer.java:723)
//      at android.view.Choreographer.doFrame(Choreographer.java:658)
//      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
//      at android.os.Handler.handleCallback(Handler.java:790)
//      at android.os.Handler.dispatchMessage(Handler.java:99)
//      at android.os.Looper.loop(Looper.java:164)
//      at android.app.ActivityThread.main(ActivityThread.java:7000)
//      at java.lang.reflect.Method.invoke(Native Method)
//      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
//      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
//
** Monkey aborted due to error.
Events injected: 19
:Sending rotation degree=0, persist=false
:Dropped: keys=0 pointers=13 trackballs=0 flips=0 rotations=0
## Network stats: elapsed time=8207ms (0ms mobile, 0ms wifi, 8207ms not connected)
** System appears to have crashed at event 19 of 500 using seed 1555759346990

It's looks like for me who a project lost references to Entity Framework, when app start it try run migration, follow my code:

public partial class App : PrismApplication
    {

    // omitted default constructors

        protected override async void OnInitialized()
        {
            InitializeComponent();
            //TODO: depois que lançar versão oficial do app remover essa rotina de exclusão de banco de dados
            using (IAppDbContext db = new AppDbContext(new DbContextOptionsBuilder<IAppDbContext>().UseSqlite(new SqliteConnection(Container.Resolve<IDBUtils>().ObterCaminhoBanco())).Options))
            {
                using (DbConnection conn = db.Database.GetDbConnection())
                {
                    if (conn.State.Equals(ConnectionState.Closed))
                    {
                        conn.Open();
                    }
                    using (var command = conn.CreateCommand())
                    {
                        command.CommandText = @"Select Count(name) from sqlite_master where type = 'table' and  name = 'Sessoes';";
                        bool baseNaoMigrada = !Convert.ToBoolean(command.ExecuteScalar());
                        if (baseNaoMigrada)
                        {
                            db.Database.EnsureDeleted();
                        }
                    }
                }
            }

            using (IAppDbContext db = new AppDbContext(new DbContextOptionsBuilder<IAppDbContext>().UseSqlite(new SqliteConnection(Container.Resolve<IDBUtils>().ObterCaminhoBanco())).Options))
            {
                db.Database.Migrate();
            }
            string pagina = SessaoUsuario.UsuarioEstaLogado ? string.Format("/" + ViewsNamesConstants.PREFIXO_VIEW_MASTER_DETAIL, ViewsNamesConstants.MASTER_DETAIL, ViewsNamesConstants.MAPA) : string.Format(ViewsNamesConstants.PREFIXO_VIEW, ViewsNamesConstants.LOGIN);
            await NavigationService.NavigateAsync(pagina);
        }

         // omitted OnResume, OnSleep and RegisterTypes
    }

thank you :)

Adware on Microsoft Ads on UWP apps?

Surround a letter

$
0
0

Hello,
I want surround a letter by black color for better readability, I use Shadow effect but with this effect only 2 sides are surround, How do this on Android and IOS ?

See the effect on D 1000

Nursery full warnings on Forms 4.0.0.346134-pre9

$
0
0

Upgrading an app from pre8 to pre9 results in a ton of "Nursery Full" warnings, and the app never launches in the Pie 9 emulator. Reverting back to pre8 fixes the issue. Code has not changed.

GC_TAR_BRIDGE bridges 0 objects 0 opaque 0 colors 0 colors-bridged 0 colors-visible 19 xref 0 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.06ms tarjan 0.06ms scc-setup 0.06ms gather-xref 0.04ms xref-setup 0.04ms cleanup 0.05ms
GC_BRIDGE: Complete, was running for 0.42ms
GC_MINOR: (Nursery full) time 1.20ms, stw 1.93ms promoted 0K major size: 2176K in use: 1494K los size: 0K in use: 0K

...

ad inifnitum

Working with Mapbox on Forms

$
0
0

Hey there!

After reading through the changes in pricing of the Google Maps API, I've decided to change to another map solution for a project I'm currently on. The best choice seems at the moment to be Mapbox.

However, I've been running into some issues, chiefly among them the apparent lack of documentation/support. The official Xamarin SDKfor Mapbox recommends that you code the maps separately for iOS and Android, which honestly seems to defeat the point of using Xamarin at all, as the map will be the main feature of the app (to display registered locations on).

Also found a library by Naxam (can't post links as the account is new), which might add exactly what I'm looking for, but it has pretty much 0 documentation, and so wouldn't make my life that much easier.

Other alternatives I've looked into were Bing and Here, with both (apparently) being even less supported.

Am I missing something or is Forms just not that good if you wanna work with maps? It's acceptable with Google Maps - sharing most of the code other than the custom renderers -, and I've got a prototype of the app running with it just fine, but anything other than that appears to be lacking. Should I just accept it and do everything on the native code?

Xamarin TapGestureRecognizer sometime does not work properly

$
0
0

I am currently building my mobile application using Xamarin.Forms and i encountered a problem (on both platform of ios and android) when i tried to use Xamarin.Forms gestures more particularly a tap gesture on a xaml Label. Because i want to use this label as a link.

The problem is that this tab gesture that i used does not work sometime ( approximately 5 times test = 1 time bug).

During DEBUG when the problem occured i see that the tabbing is still recognized but it did not respond in the action i set up.

It occurs on both iOS and Android devices.

Here is my XAML code:
<RelativeLayout> <Image Source="icon_question" WidthRequest="15" HeightRequest="15"></Image> <Label Margin="15, -3, 0, 0" HorizontalOptions="CenterAndExpand" HorizontalTextAlignment="Center" Text="Some text" TextColor="Blue" FontSize="15" TextDecorations="Underline"> <Label.GestureRecognizers> <TapGestureRecognizer Tapped="_tabLinkForgetPassword"></TapGestureRecognizer> </Label.GestureRecognizers> </Label> </RelativeLayout>

and here is my code behind:

private void _tabLinkForgetPassword(object s, EventArgs e) { App.Current.MainPage = new ResetPasswordPage(false); }


How to design a bottom navigation bar?

$
0
0

I am trying to design a bottom navigation bar in my project . But i am not understanding how to do. Any suggestion please?

How to get setting of Color in XAML-ResourceDictionary using C#,要怎麼在C#中讀取XAML-ResourceDictionary中的顏色

$
0
0

我有放了幾個顏色在ResourceDictionary中 如:
I use ResourceDictionary to pack some color settings,like

    <ResourceDictionary x:Name="The_Resources">
        <!--Global Styles-->
        <Color x:Key="color_A">#2196F3</Color>
        <Color x:Key="color_B">Khaki</Color>
        <Color x:Key="color_C">Coral</Color>

        <Style x:Key="Button_Style" TargetType="Button"    x:Name="Button_Style">
            <Setter Property="FontAttributes" Value="Bold" />
            <Setter Property="BackgroundColor" Value="{StaticResource color_B}" />
            <Setter Property="FontSize" Value="Default" />
        </Style>
      </ResourceDictionary >

C#可以用這樣的方式讀取ResourceDictionary的Style:
C# can get the Style in ResourceDictionary just like:

        Button 按鈕 = new Button
        {
            //BackgroundColor = Color.LightSteelBlue,
            Style = App.Current.Resources["Button_Style"] as Style,
        };

但要怎麼在C#中取得Colo_A B C的顏色賦予BackgroundColor呢?
but can C# read Color_A B C to set BackgroundColor?

Disable highlight on ViewCell tap

$
0
0

Hi,

How can I prevent the highlight happens when tapping on ViewCell without having to disable the the ViewCell (IsEnabled=false) because that will also disable the Tapping which I need..

Here is my XAML with Thanks..

<TableSection Title="Privacy">
    <ViewCell>
        <Grid x:Name="SettingsPrivacyGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Label Text="Show my Email" Grid.Row="0" Grid.Column="0" HorizontalOptions="FillAndExpand" />
            <Switch x:Name="SettingsSwitchShowMyEmail" Grid.Row="0" Grid.Column="1" Toggled="SettingsSwitchShowMyEmail_Toggled" />

            <Label Text="Show my Mobile" Grid.Row="1" Grid.Column="0" HorizontalOptions="FillAndExpand" />
            <Switch x:Name="SettingsSwitchShowMyMobile" Grid.Row="1" Grid.Column="1" Toggled="SettingsSwitchShowMyMobile_Toggled" />

            <Label Text="Others can Message Me" Grid.Row="2" Grid.Column="0" HorizontalOptions="FillAndExpand" />
            <Switch x:Name="SettingsSwitchOthersMessageMe" Grid.Row="2" Grid.Column="1" Toggled="SettingsSwitchOthersMessageMe_Toggled" />
        </Grid>
    </ViewCell>
</TableSection>

How to insert all data using InsertAllAsync

$
0
0

Hello.. anyone know how to insert all data using InsertAllAsync.. i want to insert all data before i delete data in sqlite.

Xamarin Forms and animated GIF

$
0
0

I've searched this for, I think, 3 or 4 days until now.
I cannot find a coherent way to add an animated GIF to my Forms apps.

Is such a thing possible?

Thanks in advance.

Viewing all 77050 articles
Browse latest View live