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

Binding form to class

$
0
0

Hi, I have also some trouble setting up binding with my form. this is what I have at the moment. when debugging. the properties are always null... ive tried adding the notifypropertychanged function in the xaml.cs but this didnt work.

XAML:
``
x:Class="DestinationsApp.AddDestinyPage">

<StackLayout Margin="10,10,10,0" BindingContext="{x:Binding Destiny}">
    <Label Text="Add destiny" Margin="10" HorizontalTextAlignment="Center" FontSize="Title" TextColor="Black"/>
    <Label Text="Country" FontSize="Title" TextColor="Black"/>
    <Entry x:Name="eCountry" Text="{Binding Country, Mode=OneWay}"/>
    <Label Text="City" FontSize="Title" TextColor="Black"/>
    <Entry x:Name="eCity" Text="{Binding City,Mode=OneWay}"/>
    <Label Text="Type" FontSize="Title" TextColor="Black"/>
    <Picker x:Name="pType" SelectedItem="{Binding Type, Mode=OneWay}">
        <Picker.Items>
            <x:String>Appartment</x:String>
            <x:String>Hotel</x:String>
            <x:String>Camping</x:String>
        </Picker.Items>
    </Picker>
    <Button x:Name="btnAddDestiny" Text="Add destiny" Clicked="btnAddDestiny_Clicked"/>
</StackLayout>

``

XAML.CS:

``
public partial class AddDestinyPage : ContentPage, INotifyPropertyChanged
{
private Destiny _Destiny;

    public Destiny Destiny
    {
        get { return _Destiny; }
        set { _Destiny = value; OnPropertyChanged(); }
    }

    public AddDestinyPage()
    {
        InitializeComponent();
        Destiny = new Destiny();
        //BindingContext = Destiny;
    }

    private async void btnAddDestiny_Clicked(object sender, EventArgs e)
    {

        if (string.IsNullOrWhiteSpace(Destiny.Country) ||
            string.IsNullOrWhiteSpace(Destiny.City) ||
            string.IsNullOrWhiteSpace(Destiny.Type))
        {
    }
}
}

``

Class:
``
public class Destiny : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] String propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private string _ID;

    public string ID
    {
        get { return _ID; }
        set { _ID = value; OnPropertyChanged(nameof(ID)); }
    }

    private string _Country;

    public string Country
    {
        get { return _Country; }
        set { _Country = value; OnPropertyChanged(nameof(Country)); }
    }

    private string _City;

    public string City
    {
        get { return _City; }
        set { _City = value; OnPropertyChanged(nameof(City)); }
    }

    private string _Type;

    public string Type
    {
        get { return _Type; }
        set { _Type = value; OnPropertyChanged(nameof(Type)); }
    }
}

``


Xamarin Forms Firebase Cloud Messaging

$
0
0

i've configuring my xamarin form apps for 1 week and still no luck. im using latest xamarin form. the issue is OnNewToken method is not called.

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

using Android.App;
using Android.Content;
using Android.Graphics;
using Android.Media;
using Android.OS;
using Android.Runtime;
using Android.Support.V4.App;
using Android.Util;
using Android.Views;
using Android.Widget;
using Firebase.Messaging;

namespace XamarinFirebaseExample.Droid
{
    [Service(Name = "mypackage.MyFirebaseMessagingService")]
    [IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
    public class MyFirebaseMessagingService : FirebaseMessagingService
    {
        private const string defaultNotificationTitle = "App name";
        private const string newsChannelId = "1"; // not sure I just use 1 you should be able to use anything as long as its unique per channel
        private const string newsChannelDescription = "Channel name shown to user e.g. News";
        private long[] vibrationPattern = { 500, 500, 500, 500, 500, 500, 500, 500, 500 };
        private NotificationManager notificationManager;

        public override void OnNewToken(string newToken)
        {
            base.OnNewToken(newToken);
            Log.Info("MyFirebaseMessagingService", "Firebase Token: " + newToken);
            saveRegistrationToApp(newToken);
        }

        public override void OnMessageReceived(RemoteMessage remoteMessage)
        {
            base.OnMessageReceived(remoteMessage);
            // depending on how you send the notifications you might get the message as per documentation
            // using remoteMessage.getNotification().getBody()
            var message = remoteMessage.Data["message"];
            Log.Debug("MyFirebaseMessagingService", "From:    " + remoteMessage.From);
            Log.Debug("MyFirebaseMessagingService", "Message: " + message);

            sendNotification(defaultNotificationTitle, message);
        }

        private void sendNotification(string title, string message)
        {
            var intent = new Intent(this, typeof(MainActivity));
            intent.AddFlags(ActivityFlags.SingleTop);
            var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
            notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
            {
                NotificationImportance importance = NotificationImportance.High;
                NotificationChannel notificationChannel = new NotificationChannel(newsChannelId, newsChannelDescription, importance);
                notificationChannel.EnableLights(true);
                notificationChannel.LightColor = Color.Red;
                notificationChannel.EnableVibration(true);
                notificationChannel.SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification), new AudioAttributes.Builder()
            .SetContentType(AudioContentType.Sonification)
            .SetUsage(AudioUsageKind.Notification)
            .Build());
                notificationManager.CreateNotificationChannel(notificationChannel);
            }

            Notification notification = new NotificationCompat.Builder(this, newsChannelId)
                .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Mipmap.icon)) //newest projects use mipmaps and drawables, you can go to drawables too
                .SetSmallIcon(Resource.Mipmap.icon)
                .SetContentTitle(title)
                .SetContentText(message)
                .SetAutoCancel(true)
                .SetVisibility((int)NotificationVisibility.Private)
                .SetContentIntent(pendingIntent)
                .SetVibrate(vibrationPattern)
                .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                .Build();

            notificationManager.Notify(0, notification); // overrides old notification if it's still visible because it uses same Id
        }

        private void saveRegistrationToApp(string token)
        {
           // send to server or store locally
        }
    }
}

Xamarin Forms Database backup sqlite

$
0
0

This is my code to take sqlite backup. There are no errors but can't find any database file in my location.

Please help.

How to change Label TextColor with binding property of ViewModel in MVVM?

$
0
0

<Label Text="EmpName" TextColor="{Binding emp_color}" />
I have created Label control with TextColor bindable property which is declared in ViewModel in separate project from Xamarin.Forms and Native. I need to change this Label TextColor dynamically.

Xamarin.Forms.Forms doesn't exist after updating Xamarin.Forms

$
0
0

I was using this for the following implementations:

Xamarin.Forms.Forms.Init(...)
Xamarin.Forms.Forms.Context.GetSystemService(...)

However, since updating my android project to the latest version of Xamarin.Forms. The Xamarin.Forms.Forms namespace does not exist. Why would you remove a namespace like this? Where is the init method moved to? This is breaking my code and I can't build without this fixed.

How do we implement **Proctoring** in Xamarin forms? Is there any tool available for it?

xamarin forms android device database location

$
0
0

I can't find sqlite database in my project. In file folder there are no database. its empty. But my data is saving successfully and its loading. Please help

/data/user/0/com.companyname.MyApp/files/

This is my database path.

       var dbName = "dbApp.sqlite";
       var dbpath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
       var path = Path.Combine(dbpath,dbName);
       var conn = new SQLiteConnection(path);

Draw numbers inside of a circle using SkiaSharp - Xamarin Forms

$
0
0

I want to create custom pins using SkiaSharp where I have a PinIcon.png which is simply a circle icon that's filled in with colour. I want to have numbers starting from 1 inside the pins, then add these numbered icons to the pins, and I figured that SkiaSharp was the best option. I cannot seem to draw on images using SkiaSharp, even though there is a lot of documentation.

I was thinking of something like below:

for( i = 1, i < pinlist.count, i++)
{
// numberedPin = PinIcon.Draw(i.ToString())
}


How to style shell content title and menu item title property in xamarin forms shell

$
0
0

Is it possible to set the font size and text color for menu items in xamarin forms shell? is styling possible for menu items /Shell items in xamarin forms shell?


<MenuItem Text="Help"
IconImageSource="help.png"
Command="{Binding HelpCommand}"

in the above code, how to style text property ?

Xamarin.Forms: Plugin.Geofence not showing notifications

$
0
0

I am using the https://github.com/CrossGeeks/GeofencePlugin Plugin.Geofence 1.5.4 nuget for Xamarin Forms trying to experiment with some geofences. Everything seems to work fine, but no notifications are showed on entry/stay/exit

` var request = new GeolocationRequest(GeolocationAccuracy.Medium);
var location = await Geolocation.GetLocationAsync(request);
Latitude = location.Latitude;
Longitude = location.Longitude;
CrossGeofence.Current.StartMonitoring(new GeofenceCircularRegion("My Region", Latitude,Longitude, 500)
{

                //To get notified if user stays in region for at least 5 minutes
                NotifyOnStay = true,
                NotifyOnEntry = true,
                NotifyOnExit = true,
                ShowNotification = true,
                ShowEntryNotification = true,
                ShowExitNotification = true,
                ShowStayNotification = true,
                Persistent = true,
                StayedInThresholdDuration = TimeSpan.FromMinutes(5)

            });`

Xamarin.Forms Tabbad Page on Android not working

$
0
0

Hello,
the error message is

System.InvalidCastException: 'Unable to convert instance of type 'Android.Widget.LinearLayout' to type 'Android.Support.Design.Widget.TabLayout'.'

everthing working fine on UWP, but on Android the App is crashing after the navigation.
Navigation works after I press a button

private void GoToTabPCommand() { Navigation.PushAsync(new NavigationPage( new TabPage())); }

Tried online solution like deleting .bin Folder and obj. Folder.
Xamarin.Android.Support.Animated.Vector.Drawable 28.0.0.3
Xamarin.Android.Support.Vector.Drawable 28.0.0.3
Xamarin.Forms Tried 4.4.0.991537 (highest current stable version)
also 4.3 ... 4.2 (different Versions)

Android is a physically Phone current with API 29

How to mark an area as Home/Safe zone on Google map?

$
0
0

Hi everyone,
I am working on an app in which I need to mark an area as Home/Safe on google map. I am really confuse which method should I use . I did some R&D but didn't find any exact way to do that.
For example suppose when we enter into the house we can mark that area as Home on google map and it will show the whole area of the house length and width of the house on google map which has been mark as home.

xamarin

Find a control inside ContentPage.Resources by name not index

$
0
0

Hi,

I have the following ContentPage.Resources inside my ContentPage:

<?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"
    xmlns:SyncfusionBusyIndicator="clr-namespace:Syncfusion.SfBusyIndicator.XForms;assembly=Syncfusion.SfBusyIndicator.XForms"
    xmlns:SyncfusionInputLayout="clr-namespace:Syncfusion.XForms.TextInputLayout;assembly=Syncfusion.Core.XForms"
    xmlns:SyncfusionButtons="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
    xmlns:FFImageLoading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
    xmlns:SyncfusionMaskedEdit="clr-namespace:Syncfusion.XForms.MaskedEdit;assembly=Syncfusion.SfMaskedEdit.XForms"
    xmlns:SyncfusionPicker="clr-namespace:Syncfusion.SfPicker.XForms;assembly=Syncfusion.SfPicker.XForms"
    mc:Ignorable="d" BackgroundColor="White"
    x:Class="Angels.Signup">
    <ContentPage.Resources>
        <ResourceDictionary>
            <ContentView BackgroundColor="White" x:Key="ActivationPINContentView">
                <StackLayout x:Name="StackLayoutActivationPIN">
                    <Grid x:Name="GridActivationPIN" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="15">
                        <SyncfusionInputLayout:SfTextInputLayout Hint="Activation PIN" Margin="0,0,0,10" ContainerType="Outlined">
                            <SyncfusionMaskedEdit:SfMaskedEdit x:Name="MaskedEditActivationPIN" ValidationMode="KeyPress" FontSize="Medium" HeightRequest="60" MaskType="Text" Mask="0  0  0  0  0  0" ValueMaskFormat="ExcludePromptAndLiterals" CutCopyMaskFormat="ExcludePromptAndLiterals" HorizontalTextAlignment="Center" FlowDirection="LeftToRight" HorizontalOptions="FillAndExpand" Keyboard="Numeric" />
                        </SyncfusionInputLayout:SfTextInputLayout>
                    </Grid>
                </StackLayout>
            </ContentView>
        </ResourceDictionary>
    </ContentPage.Resources>
     ......................................................
     ......................................................
     ......................................................
     ......................................................

I am currently doing this:

contentView = (ContentView)Resources["ActivationPINContentView"];

stackEditor = contentView.Content as StackLayout;
gridEditor = stackEditor.Children[0] as Grid;
maskedEdit = (gridEditor.Children[0] as SfTextInputLayout).InputView as SfMaskedEdit;

But i want to ask is it possible to reach the MaskedEditActivationPIN by name instead of going through each layer..

So what I am looking for is something like this:

FindByName("MaskedEditActivationPIN");

Thanks,
Jassim

Page based On Device

$
0
0

If Device is tablet means, I want content page and if Device is phone means I want Master detail page. How to achieve it.Any suggestion please............

Store list of data

$
0
0

What is the most efficient way to store list of data? I will write values locally on the device each minute, and then I would like to perform searches/grouping on that data. The data is basically a List where T is a general POCO that holds a DateTime and some doubles. I will need to sort the data and so on. Is it best to just use a file on the device or SQLLite or something else? The storage would also need to be thread safe, i.e it might happen that my service writes to the list during search in it. In worst case the list will hold a few thousands of objects.


How to generate notifications when the application is closed?

$
0
0

I am developing an example app, with the most important concepts (notifications, consumption of apis, etc.).

I can generate notifications, but I always have to have the application open, even in the background. The idea is that although the application is closed, there is some process that allows me every time interval to execute an action and if it is true, it shows a notification.

For example, most of us use the Facebook, Instragram and Whatsup apps, and these applications, even if they are closed when there is a new message, show us a notification. It is really what I would like to achieve.

If you could help me, I would really appreciate it and thank you for what you have helped me so far.

How could you do this to make it work for Android and IOS?

I thank you very much for your help.

Best approach to create controls dynamically in a List

$
0
0

Hi,

There is a requirement to populate the list of items, each item with an icon(s), input boxes / editors and list views to show for each item in the list.
We started creating the controls dynamically based on conditions.
When the count of parent list item increases, we see that there is a performance hindrance to load the parent list view.

When the count of parent list is reaching to over 200+ items, the list rendering very slowly. And the text boxes is taking time to enter the values on tapped.

We knew that there are lots of stacks within each ListView item, but we cannot avoid it as it has tons of validations on each control.

Any suggestions to improve the performance is much appreciated.

Xamarin and ChromeCast

$
0
0

We would like to create an app in Xamarin for phones and tablets (both Android and iOS) that can use Google ChromeCast (like YouTube, Vimeo, Facebook, etc.). The app should be able to crhomecaste a movie from the app to eg a TV (via chromecast).

The libraries that is available do not seem to be up to date and work properly.

We would really appreciate to get in contact with a person/company who has succeeded in making chromecast in a Xamarin app that works properly and is active in the Apple App Store and Google Play Store.

Does anyone here have knowledge about an app built in Xamarin that uses Chromecast that works properly?

Change Shell Flyout Header Label from C#

$
0
0

I'm using a custom Flyout Header in my Shell app and I want to change the label from my code while starting the app but I haven't got it to work. Code comes from Xanimals sample.

<Shell.FlyoutHeaderTemplate>
        <DataTemplate>
            <Grid BackgroundColor="Black"
                  HeightRequest="200">
                <Image Aspect="AspectFill" 
                       Source="xamarinstore.jpg" 
                       Opacity="0.6" />
                <Label Text="Animals" 
            x:Name="InfoLabel"
                       TextColor="White" 
                       FontAttributes="Bold" 
                       HorizontalTextAlignment="Center"
                       VerticalTextAlignment="Center" />
            </Grid>            
        </DataTemplate>
</Shell.FlyoutHeaderTemplate>

The name InfoLabel isn't accessable by code. What to do?

send files using bluetooth in xamarin forms ios and android

$
0
0

hello guys,

i am currently doing project for file transfer using Bluetooth between two device using xamarin forms(.net standard) but i cant find relevant documentation for how to do this i know there is a plugin for data transfer https://github.com/aritchie/bluetoothle but i am not sure if it can transfer files please help me out on this.

thanks in advance.

Viewing all 77050 articles
Browse latest View live


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