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

Editor in sub-ListView doesn't work correctly

$
0
0

Hi,
I have a list of items. Each item can have some subitems.
When displaying the items ListView with a nested subitems ListView, the Editor views in the sub-ListView doesn't behave as expected.
SubItem Editors can't be focussed until you focus an Item's Editor component.

You can find an example here: https://github.com/pinki/XFListInList

I don't know if there's also a problem on iOS, but on Android it's as written above.

Am I doing something wrong or is there a bug?


Library Reference

$
0
0

As i have solved the web references and the stuff like that, i am presented with another obstacle which i have been trying to solve, but basically, in my Xamarin.Forms i would like to add a library called System.Web.Services which will allow the code to get the .Credentials that it needs, and i have been presented with this problem

Any Solutions, while i keep looking for the answer.

why datagrid is empty

$
0
0

I want to show data in datagrid data from product ,SalesOrderItem using entityframework and sqlite

Models are
public class Customer
{
[Key]
public int CustomerId { get; set; }
public string MangerFullName { get { return FirstName + " " + LastName; } }
public string EntrpriseName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string CIN { get; set; }
}
}
public class SalesOrder
{

[Key]
public int SalesOrderId { get; set; }
public string NumBc { get { return "BC" + SalesOrderId; } }
public string Ref { get; set; }
public DateTime? DateLivraison { get; set; }
public DateTime? DateCreation { get; set; }
public string Image { get; set; }
public string Etat { get; set; }
public double TotalHt { get; set; }
public int TVA { get; set; }
public double TotalTTC { get; set; }
  public int Total { get; set; }


public int CustomerId { get; set; }
[ForeignKey("CustomerId")]
public virtual Customer Customer { get; set; }

public ICollection<SalesOrderItem> SalesOrderItems { get; set; }

}
}
public class Product
{
[Key]
public int ProductId { get; set; }
public string Code { get; set; }
public string Designation { get; set; }
public int Quantite { get; set; }
public double PrixUnitaire { get; set; }
public string Type { get; set; }
public ICollection SalesOrderItems { get; set; }
}
}
public class SalesOrderItem
{
[Key]
public int SalesOrderItemId { get; set; }
public int Order_Qty { get; set; }
public double TotalHt { get; set; }

public int SalesOrderId { get; set; }
[ForeignKey(("Fk_ SalesOrderId"))]
public virtual SalesOrder SalesOrder  { get; set; }
public int ProductId { get; set; }
[ForeignKey(("Fk_ProductId"))]
public virtual Product Product { get; set; }

}
}
viewModel
public SalesOrderDetailsVM(int salesOrderItemId)
{
_salesOrderId = salesOrderItemId;

    _context = new DatabaseContext();

    var salesOrderItem = _context.SalesOrderItems.Find(salesOrderItemId);
    var idsalesOrder = salesOrderItem.SalesOrderId;
    var salesOrder = _context.SalesOrders.Find(idsalesOrder);
    var idProd = salesOrderItem.ProductId;
    _context = new DatabaseContext();

    var Customer = _context.Customers.Where(t => t.CustomerId == salesOrder.CustomerId).FirstOrDefault();
    // Setting property values from object
    // that we get from database
    DateCreation = salesOrder.DateCreation;
    NumBc = salesOrder.NumBc;
    CustomerName = Customer.MangerFullName;
    CustomerCIN = Customer.CIN;

     var Products = _context.Products.Where(x => x.SalesOrderItems.Any(y => y.SalesOrderItemId == salesOrderItemId)).ToList();
}

view
<ContentPage.Content>



<Grid.RowDefinitions>




</Grid.RowDefinitions>

<Grid.ColumnDefinitions>


</Grid.ColumnDefinitions>

                    <Label  Text="Code" VerticalOptions="Center"  Grid.Column="0"/>
                    <Label Text="Design" VerticalOptions="Center" Grid.Column="1" />
                    <Label Text="Q" VerticalOptions="Center" Grid.Column="2"/>
                    <Label Text="PU" VerticalOptions="Center" Grid.Column="3"/>
                    <Label Text="Total" VerticalOptions="Center" Grid.Column="4"/>
                    <BoxView BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="0" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
                    <BoxView BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="1" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
                    <BoxView BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="2" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
                    <BoxView BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="3" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
                    <BoxView BackgroundColor="DarkSlateGray" WidthRequest="1" Grid.Column="4" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"/>
                </Grid>
            </Frame>
            <ListView ItemsSource="{Binding Products}" 
                      SeparatorVisibility="Default"
                      SelectionMode="None"  
                    >

                <ListView.ItemTemplate BackgroundColor="DarkSlateGray" >
                    <DataTemplate>
                        <ViewCell>
                            <Frame Padding="5" BorderColor="DarkSlateGray">
                                <Grid Padding="5" >
                                    <Grid.ColumnDefinitions BorderColor="DarkSlateGray">
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid BackgroundColor="Transparent" >
                                        <Grid.RowDefinitions BorderColor="DarkSlateGray">
                                            <RowDefinition Height="*" />

                                        </Grid.RowDefinitions>
                                    </Grid>
                                    <Label Text="{Binding Products.Code}" VerticalOptions="Center" Grid.Column="0" />
                                    <Label Text="{Binding Products.Description}" VerticalOptions="Center" Grid.Column="1" />
                                    <Label  Text="{Binding Products.Order_Qty}" VerticalOptions="Center" Grid.Column="2" />
                                    <Label Text="{Binding Products.PrixUnitaireHt}" VerticalOptions="Center" Grid.Column="3" />
                                    <Label Text="{Binding Products.TotalHt}" VerticalOptions="Center" Grid.Column="4" />
                                </Grid>
                            </Frame>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>
    </StackLayout>
</ContentPage.Content>

How can I enable BindableLayout in xaml?

$
0
0

How can I enable BinableLayout in xaml?

I get this in xaml:

In code behind I can access BindableLayout as expected from Xamarin.Forms.

Is it possible to retrieve a class from Xamarin.Android to Xamarin.Forms using Dependency Services?

$
0
0

Recently i have included a Dependency Services to my application however, i have been trying to return atleast the class that i am going to need to access the built in services for the app to work.

These 4 properties that you see are inside the class called DB, i want to call a Dependency Service, go into that folder, get those 4 values and get them back to Xamarin.Forms, i have been messing around with the interface and i have a few solutions but i think there could be a better way to do, So if anyone knows please let me know :P

Data is not persisted between builds

$
0
0

Hello, I have a xamarin forms application and i want to save some parameters locally. I tried with SettingsPlugin and SqlLite. The problem is the same. If I debug the application from VS all the local data is cleared everytime. If i just run the deployed app from my device then both method works.

I have the "preserve application data cache on device between builds' checked.

What i am doing wrong?

Object reference not set to an instance of an object

$
0
0

I am currently making an app to display and interact with a company's employees. I have a list of departments and when a department is selected, I am trying to show only a list of employees in that department. I am pulling the departments and employees from two different JSON urls. I am trying to use linq to pull the employees where the department is the same as the selected department. I am using James Montemagno's Monkey Finder workshop to help build my app. However, when I try to load the contacts I get an object reference not set to an instance of an object error. I will put my code below for reference on what I am doing as well as screenshots of the error. Does anyone know how to fix this or what I am doing wrong? Thank you!

App Screenshots:

Code:

Model:

Contact.cs

using System;
using System.Collections.Generic;

using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace ContactNavigation.Model
{
    public partial class Contact
    {
        [JsonProperty("FirstName")]
        public string FirstName { get; set; }

        [JsonProperty("LastName")]
        public string LastName { get; set; }

        [JsonProperty("Department")]
        public string Department { get; set; }

        [JsonProperty("Position")]
        public string Position { get; set; }

        [JsonProperty("PhoneNumber")]
        public string PhoneNumber { get; set; }

        [JsonProperty("Email")]
        public string Email { get; set; }

        [JsonProperty("Picture")]
        public Uri Picture { get; set; }

        [Newtonsoft.Json.JsonIgnore]
        public string FullName { get { return FirstName + " " + LastName; } }
    }

    public partial class Contact
    {
        public static Contact[] FromJson(string json) => JsonConvert.DeserializeObject<Contact[]>(json, ContactNavigation.Model.Converter.Settings);
    }

    public static class Serialize
    {
        public static string ToJson(this Contact[] self) => JsonConvert.SerializeObject(self, ContactNavigation.Model.Converter.Settings);
    }

    internal static class Converter
    {
        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
        {
            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
            DateParseHandling = DateParseHandling.None,
            Converters =
            {
                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
            },
        };
    }
}

Services:

IDataService.cs

using ContactNavigation.Model;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace ContactNavigation.Services
{
    public interface IDataService
    {
        Task<IEnumerable<Contact>> GetContactsAsync();

        Task<IEnumerable<Department>> GetDepartmentsAsync();
    }
}

WebDataService

using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Xamarin.Forms;
using Newtonsoft.Json;
using System.Text;
using System;
using System.Linq;
using ContactNavigation.Model;
using ContactNavigation.Services;


[assembly: Dependency(typeof(WebDataService))]
namespace ContactNavigation.Services
{
    public class WebDataService : IDataService
    {
        HttpClient DepartmentsHttpClient;
        HttpClient DepartmentClient => DepartmentsHttpClient ?? (DepartmentsHttpClient = new HttpClient());

        HttpClient ContactsHttpClient;

        HttpClient ContactClient => ContactsHttpClient ?? (ContactsHttpClient = new HttpClient());

        public async Task<IEnumerable<Contact>> GetContactsAsync()
        {
            var json = await ContactClient.GetStringAsync("MyContactURLHere");
            var all = Contact.FromJson(json);
            return all;
        }

        public async Task<IEnumerable<Department>> GetDepartmentsAsync()
        {
            var json = await DepartmentClient.GetStringAsync("MyDepartmentURLHere");
            var all = Department.FromJson(json);
            return all;
        }
    }
}

ViewModel:

ContactViewModel.cs

using ContactNavigation.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms;
using System.Diagnostics;

namespace ContactNavigation.ViewModel
{
    public class ContactViewModel : BaseViewModel
    {
        public ObservableCollection<Contact> EmployeeContacts { get; }

        public Command GetContactsCommand { get; }

        public ContactViewModel()
        {
            GetContactsCommand = new Command(async () => await GetContactsAsync());
        }

        public ContactViewModel(Department department)
            : this()
        {
            Department = department;
            Title = $"{Department.DepartmentName}";

        }
        Department department;
        public Department Department
        {
            get => department;
            set
            {
                if (department == value)
                    return;

                department = value;
                OnPropertyChanged();
            }
        }

        async Task GetContactsAsync()
        {
            if (IsBusy)
                return;

            try
            {
                IsBusy = true;

                var contacts = await DataService.GetContactsAsync();

                EmployeeContacts.Clear();
                foreach (var contact in contacts.Where(x => x.Department == department.DepartmentName))
                    EmployeeContacts.Add(contact);
            }
            catch(Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }
    }
}

View:
ContactPage.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"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             xmlns:local="clr-namespace:ContactNavigation"
             xmlns:viewmodel="clr-namespace:ContactNavigation.ViewModel"
             xmlns:circle="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin"
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
             x:Class="ContactNavigation.View.ContactPage"
             ios:Page.UseSafeArea="True"
             Title="{Binding Title}"
             BackgroundColor="#57565B">
    <ContentPage.BindingContext>
        <viewmodel:ContactViewModel/>
    </ContentPage.BindingContext>
    <Grid RowSpacing="0" ColumnSpacing="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ListView ItemsSource="{Binding EmployeeContacts}"
                  CachingStrategy="RecycleElement"
                  HasUnevenRows="True"
                  Grid.ColumnSpan="2">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid ColumnSpacing="10" 
                              Padding="10">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="60"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <circle:CircleImage Source="{Binding Picture}"
                                                HorizontalOptions="Center"
                                                VerticalOptions="Center"
                                                BorderColor="{StaticResource PrimaryDark}"
                                                BorderThickness="3"
                                                WidthRequest="60"
                                                HeightRequest="60"
                                                Aspect="AspectFill"/>
                            <StackLayout Grid.Column="1"
                                         VerticalOptions="Center">
                                <Label Text="{Binding FullName}"
                                       TextColor="White"/>
                                <Label Text="{Binding Position}"
                                       TextColor="White"/>
                            </StackLayout>
                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <Button Text="Load Contacts"
                TextColor="White"
                BackgroundColor="{StaticResource PrimaryDark}"
                Command="{Binding GetContactsCommand}"
                IsEnabled="{Binding IsNotBusy}"
                Grid.Row="1"
                Grid.Column="0"
                Grid.ColumnSpan="2"/>
        <ActivityIndicator IsVisible="{Binding IsBusy}"
                           IsRunning="{Binding IsBusy}"
                           HorizontalOptions="FillAndExpand"
                           VerticalOptions="CenterAndExpand"
                           Grid.RowSpan="2"
                           Grid.ColumnSpan="2"/>
    </Grid>
</ContentPage>

ContactPage.xaml.cs

using ContactNavigation.Model;
using ContactNavigation.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace ContactNavigation.View
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class ContactPage : ContentPage
    {
        public ContactPage()
        {
            InitializeComponent();
        }

        public ContactPage(Department department)
        {
            InitializeComponent();
            BindingContext = new ContactViewModel(department);
        }
    }
}

Example to integrate firestore in Xamarin.Forms Andriod/IOS?

$
0
0

So, im trying to implement this libraries inside my project:
Firestore Android:
https://www.nuget.org/packages/Xamarin.Firebase.Firestore/60.1142.0-beta2

Firestore IOS:
https://www.nuget.org/packages/Xamarin.Firebase.iOS.CloudFirestore/

And I've only found 1 example of how to use them both:
https://github.com/yamachu/Sample-Firebase-Cloud-Firestore-Xamarin.Forms

Since I'm having problems when adding/updating in the mapping of .NET objects to Java/NSObject respectively. Does anyone know a library that provides an example of that?
Thanks!


Android debug version runs yet release crashes

$
0
0

I am working on a Xamarin Forms app for Android and iOS phones. I am trying to get a release version over to QA. The release compiles with no errors. Running the app the splash screen displays and then crashes with

[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.raptortech.reunification.local, PID: 19063
[AndroidRuntime] android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class android.support.v7.widget.FitWindowsLinearLayout
[AndroidRuntime] Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.v7.widget.FitWindowsLinearLayout
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.FitWindowsLinearLayout" on path: DexPathList[[zip file "/data/app/com.raptortech.reunification.local-JAxhHADWxd4TC35cIXcjAA==/base.apk"],nativeLibraryDirectories=[/data/app/com.raptortech.reunification.local-JAxhHADWxd4TC35cIXcjAA==/lib/x86, /data/app/com.raptortech.reunification.local-JAxhHADWxd4TC35cIXcjAA==/base.apk!/lib/x86, /system/lib]]
[AndroidRuntime] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
[AndroidRuntime] at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
[AndroidRuntime] at android.view.LayoutInflater.createView(LayoutInflater.java:606)
[AndroidRuntime] at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
[AndroidRuntime] at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
[AndroidRuntime] at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
[AndroidRuntime] at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
[AndroidRuntime] at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
[AndroidRuntime] at android.support.v7.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:631)
[AndroidRuntime] at android.support.v7.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:518)
[AndroidRuntime] at android.support.v7.app.AppCompatDelegateImpl.onPostCreate(AppCompatDelegateImpl.java:299)
[AndroidRuntime] at android.support.v7.app.AppCompatActivity.onPostCreate(AppCompatActivity.java:98)
[AndroidRuntime] at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1342)
[AndroidRuntime] at android.app.ActivityThread.handleStartActivity(ActivityThread.java:2964)
[AndroidRuntime] at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
[AndroidRuntime] at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
[AndroidRuntime] at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
[AndroidRuntime] at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
[AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:106)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:193)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:6669)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

In searching for a solution I did see others talk about a change from ?attr. I changed ?attr/actionBarSize to @dimen/abc_action_bar_default_height_material and ?attr/colorPrimary to @color/primary. The Android app still crashes. Any ideas what else could be cashing the issue?

System.Reflection.TargetInvocationException on MessagingCenter.Send

$
0
0

I'm trying to build simple navigation using MessagingCenter but I'm receiving System.Reflection.TargetInvocationException when I pressed the back button (hardware button).

Here is how I get the error;

After app load,
I hit the back button (hardware button)
Then after the app got minimized, I open it in recent app
After that, I click on Login then I got this error:

Unhandled Exception:

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

pointing on

MessagingCenter.Send<object>(this, App.EVENT_LAUNCH_MAIN_PAGE);

in Login Method in LoginPage.xaml.cs

PS: The code works well if I don't hit the back button (hardware button)

Here is the code:

        App.xaml.cs
public partial class App : Application
{
    public static string EVENT_LAUNCH_LOGIN_PAGE = "EVENT_LAUNCH_LOGIN_PAGE";
    public static string EVENT_LAUNCH_MAIN_PAGE = "EVENT_LAUNCH_MAIN_PAGE";

    public App()
    {
        InitializeComponent();

        MainPage = new App3.LoginPage();

        MessagingCenter.Subscribe<object>(this, EVENT_LAUNCH_LOGIN_PAGE, SetLoginPageAsRootPage);
        MessagingCenter.Subscribe<object>(this, EVENT_LAUNCH_MAIN_PAGE, SetMainPageAsRootPage);
    }

    private void SetLoginPageAsRootPage(object sender)
    {
        MainPage = new NavigationPage(new LoginPage());
    }

    private void SetMainPageAsRootPage(object sender)
    {
        MainPage = new NavigationPage(new App3.MainPage());
    }

    protected override void OnStart()
    {
        // Handle when your app starts
    }

    protected override void OnSleep()
    {
        // Handle when your app sleeps
    }

    protected override void OnResume()
    {
        // Handle when your app resumes
    }
}

LoginPage.xaml.cs
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class LoginPage : ContentPage
{
    public Command LoginCommand { get; }

    public LoginPage()
    {
        InitializeComponent();

        LoginCommand = new Command(() => Login());

        Button btn = new Button { Text = "Login", Command = LoginCommand };

        Content = new StackLayout
        {
            Children =
            {
                btn
            }
        };
    }

    public void Login()
    {
        MessagingCenter.Send<object>(this, App.EVENT_LAUNCH_MAIN_PAGE);
    }
}

MainPage.xaml.cs
public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();

        ToolbarItems.Add(new ToolbarItem("Logout", "", () => Logout()));
    }

    public void Logout()
    {
        MessagingCenter.Send<object>(this, App.EVENT_LAUNCH_LOGIN_PAGE);
    }
}

Xamarin.Forms *needs* a hot reload system

$
0
0

Flutter is winning the hearts and minds of developers. I can see there is already jobs opening asking for flutter knowledge. Everywhere I read about flutter, people praise one functionality: "hot reload". I tested it and it is really nice. The thing is, flutter does not need it as much as XF. On flutter, things look the same on both devices so you do not spend so much time doing micro adjustments to the UI as on XF. The thing, I think, is that people learning need to see the changes they make to understand and learn. A person that does not know xaml will have a hard time even doing basic things look half decent. An experienced developer will have a hard time making things look exactly how he wants. It is possible but takes a lot of time.

I know about LiveXAML (http://www.livexaml.com/), I use it and it mostly works but it is not free. I know about XAMLator (https://github.com/ylatuya/XAMLator) and HotReload (https://github.com/AndreiMisiukevich/HotReload) but one only works on mac and the other I could not make work on android emulators. So, if this amazing developers are doing it, it is possible.

I think the most important thing for this feature is to be able to edit xaml on VS and see the change on emulators (android and iOS). It would be amazing if it could reload code changes too but only xaml will be a good start. It would be nice too if it could work without Visual Studio too, so I can edit .xaml files on VSCode and see the changes on my running app. This would make things so much better for experienced developers and for newcomers.

So my question is: when will Xamarin.Forms have an official hot reload system?

App Shell - pop to root on tab tap

$
0
0

For apps like Spotify & instagram, when a user taps on a bottom tab, and the user is already on that tab, it triggers an action for that tab's navigation to pop to root.
How can we achieve this with App Shell Tabs?

How does one Programmatically determine the Screen Inch size of a device?

$
0
0

How does one Programmatically determine the Screen Inch size of a device i.e. 5", 5.7", etc.?

Need a Good Example of Saving to Android External Data Using Xamarin.Forms

$
0
0

There are a couple good write ups on the the MS Xamarin site on using Internal and External data on Xamarin.Android.
https://docs.microsoft.com/en-us/xamarin/android/platform/files/
https://docs.microsoft.com/en-us/xamarin/android/platform/files/external-storage

However, these do not explain how to access these capabilities in Xamarin.Forms. I have searched and not found a good Xamarin.Forms example of how to copy an app file (sqlite.db3 file in my case) to an Android folder that can be copied from phone using file explorer.

I found this one that looks like the correct direction but the examples are quite brief. I think the author expected the reader to know how to create these delegates.
https://kimsereyblog.blogspot.com/2016/11/differences-between-internal-and.html

I am new to Xamarin.Forms and very inexperienced in Xamarin.Android. Any guidance appreciated.

xamarin forms: InvalidRegistration error in postman when try to send notification to ios device

$
0
0

I am implementing push notifications using FCM in my Xamarin.Forms project. In the iOS project, I am getting the fcmtoken from RegisteredForRemoteNotifications. When I am sending a notification for the token by Postman I am getting InvalidRegistration error. I already worked on the android part and notification is successfully delivered for android device.

AppDelegate.cs

public async override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            if (deviceToken == null)
            {
                return;
            }
            Console.WriteLine($"Token received: {deviceToken}");
            await SendRegistrationTokenToMainPRoject(deviceToken);
        }

        async Task SendRegistrationTokenToMainPRoject(NSData deviceToken)
        {
            MessagingCenter.Send<object, string>(this, "fcmtoken", deviceToken.ToString());
        }

        public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
        {
            Console.WriteLine($"Failed to register for remote notifications: {error.Description}");
        }

Postman Response

{
    "multicast_id": 8754155136812875313,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
        {
            "error": "InvalidRegistration"
        }
    ]
}

Postman Body

 {
    "to" : "d20ad003 7473bfba 85dffc33 1534decf b4b886f1 c738878f fd7f2c60 d9dabc36",
 "collapse_key" : "type_a",
 "data" : {
     "body" : "Body of Your Notification in Data",
     "title": "Title of Your Notification in Title",
     "key_1" : "Value for key_1",
     "key_2" : "Value for key_2"
 },
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification",
     "sound": "default",
     "content_available" : true
 }
}

I am not using any NuGet packages like FirebasePushNotificationPlugin in IOS. I am receiving the devicefcmtoken in log but pushing from postman results InvalidRegistration error.

Found the same thread here, So I installed FirebasePushNotificationPlugin in IOS and capture the devicefcmtoken by the following code, but FirebaseInstanceIdcould not be found error is getting.

var fcmToken = FirebaseInstanceId.Instance.Token;

How can I solve this issue?


How to resolve errors in Resource.designer.cs when building for Android

$
0
0

My Android build has been reporting errors in Resource.designer.cs, an automatically generated file. The errors result from a full-stop (aka period) being in a couple of entries in the .cs file, as per the image below.

If I look in G:\tfs\myapp\myapp\AndroidForForms\AndroidForForms.Android\Resources\Resource.designer.cs
I see:

            // aapt resource value: 0x7f0b008c
            public const int bottomtab_navarea = 2131427468;

            // aapt resource value: 0x7f0b008d
            public const int bottomtab_tabbar = 2131427469;

But if I look in G:\tfs\myapp\myapp\AndroidForForms\AndroidForForms.Android\obj\Debug\81\designtime\Resource.designer.cs
I see the erroneous

            // aapt resource value: 0x7F030180
            public const int bottomtab.navarea = 2130903424;

            // aapt resource value: 0x7F030181
            public const int bottomtab.tabbar = 2130903425;

Any idea what might be causing this, and how I can fix it? (it was happening before I changed my PCLs to .Net Standard 2, and is still happening afterwards)

Can we override the clickevent for shell?

$
0
0

I'm using the shell in xamarin forms, I want to get the event of the click because I want to return to the rootpage when clicking one of the tab.

display PDF in webview not working Xamarin forms

$
0
0

i am trying to display a hosted IMAGE from a secure web api it working

    <WebView
                    HorizontalOptions="FillAndExpand"
                    Source="*://192.168.137.1:3581/Uploads/04-02_1.jpg"
                    VerticalOptions="FillAndExpand" />

but trying to display a hosted PDF from a secure web api it not working

<WebView
                HorizontalOptions="FillAndExpand"
                Source="*://192.168.137.1:3581/Uploads/3.pdf"
                VerticalOptions="FillAndExpand" />

*= http

Problem to Accessing Remote Data

$
0
0

Hello everyone my name is Taniguchi and i have this code to connect to dynamics 365 enviromment
public MainPage()
{
InitializeComponent();
}
private void PressMeButton_Clicked(object sender, EventArgs e)
{
(sender as Button).Text = "I was just clicked!";
var contacts = CrmRequest(
HttpMethod.Get,
"https://ax4bdev.api.crm2.dynamics.com/api/data/v9.1/contacts")
.Result.Content.ReadAsStringAsync();
}

    public async Task<String>  AccessTokenGenerator()
    {
        string redirectUrl = "https://ax4bdev.api.crm2.dynamics.com/api/data/v9.1/";//url da api da instancia do dynamics
        string clientId = "2b121ed5-9fe6-4ddf-bdea-9bbe8cd37bd0";
        string clientSecret = "_BMqI@uk2tq_@aKKI17rn3M8WzWTeehZ";
        string authority = "https://login.microsoftonline.com/21c3dfd6-b6f1-4b0a-87e8-c4b017582110";
        string resourceUrl = "https://ax4bdev.crm2.dynamics.com/";
        ClientCredential credentials = new ClientCredential(clientId, clientSecret);
        var authContext = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext(authority);
        var result = await authContext.AcquireTokenAsync(resourceUrl, credentials);
        return result.AccessToken;
    }
    public async Task<HttpResponseMessage> CrmRequest(HttpMethod httpMethod, string requestUri, string body = null)
    {
        // Acquiring Access Token  
        var accessToken = await AccessTokenGenerator();

        var client = new HttpClient();
        var message = new HttpRequestMessage(httpMethod, requestUri);

        // OData related headers  
        message.Headers.Add("OData-MaxVersion", "4.0");
        message.Headers.Add("OData-Version", "4.0");
        message.Headers.Add("Prefer", "odata.include-annotations=\"*\"");

        // Passing AccessToken in Authentication header  
        message.Headers.Add("Authorization", $"Bearer {accessToken}");

        // Adding body content in HTTP request   
        if (body != null)
            message.Content = new StringContent(body, UnicodeEncoding.UTF8, "application/json");

        return await client.SendAsync(message);
    }

but on my android emulator it doenst appear the screen for to log into dynamics enviroments intead dont happen nothing, doenst appear any error messages when i try to debug when a pass this line var result = await authContext.AcquireTokenAsync(resourceUrl, credentials); dont happens nothing next it like the code frozed.
is there somenthing to actvite to appear the log into screen or the code is placed somethere else ?
thanks for help

How I can implement pay with debit/credit card in Xamarin.Forms?

Viewing all 91519 articles
Browse latest View live


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