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

Button Image Aligment on iOS

$
0
0

I'm working with Xamarin Forms and the Button Image it's ok in Android, but not in iOS

this is the XAML

<Button x:Name="BtnOcorrencia" Image="ic_ocorrencia2" ContentLayout="top,0" BackgroundColor="White" TextColor="#05234f"  Text="Ocorrências" VerticalOptions="Center" HorizontalOptions="Center"   WidthRequest="120" HeightRequest="110" TranslationX="0"  />

The image is misaligned with the text inside the button, as in the attached image.

I try change ContentLayout but I failed,

Someone can help me?


How to unsubscribe from forum emails

$
0
0

Years ago I managed to subscribe to email notifications for posts to the Xamarin.Forms section.
Meaning I get an email each time a new thread is posted.
Its been so long that I forget how to UNsubscribe so I no longer get emails for each new thread to the section.
Its not in profile, or notification settings that I can find.
There's no "favorites star" like at the top of a single thread.
It doesn't seem to be 'starred' in my bookmarks.
What am I missing or not seeing?

Also... Any way to unbookmark all?
https://forums.xamarin.com/discussions/bookmarked/

I don't need notifications from 6 pages of threads and really don't want to have to manually untick every one. Surely there's an "unbookmark all" someplace.

Number from/to animation

$
0
0

Hey there, everyone. I made a simple behavior which provides number from/to animation (e.g. counter). I'm sharing the code below for whoever needs it and I'm looking to some suggestions on how to improve this code :).

https://youtube.com/watch?v=3ciQWIaARN0

using System;
using System.Threading;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace MyApp.Behaviors
{
    public class NumericLabelFromToBehavior : Behavior<Label>
    {
        public static readonly BindableProperty TextProperty =
            BindableProperty.Create(
                nameof(Text),
                typeof(double),
                typeof(LabelHighlightAndStepOnChangeBehavior),
                null,
                propertyChanged: OnTextPropertyChanged);

        public double Text
        {
            get { return (double)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        public Label AssociatedObject { get; private set; }

        private static CancellationTokenSource cancellationTokenSource;

        private static long currentValue = 0;

        private static void OnTextPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var behavior = (NumericLabelFromToBehavior)bindable;
            if (behavior.AssociatedObject == null)
            {
                return;
            }
            cancellationTokenSource?.Cancel();
            cancellationTokenSource = new CancellationTokenSource();
            Task.Run(() => AnimateText(behavior.AssociatedObject, currentValue, newValue, cancellationTokenSource.Token), cancellationTokenSource.Token);
        }

        private static async void AnimateText(BindableObject bindable, object fromValue, object toValue, CancellationToken cancellationToken)
        {
            long.TryParse(fromValue.ToString(), out long initialValue);
            long.TryParse(toValue.ToString(), out long finalValue);

            if (initialValue < finalValue)
            {
                var step = Math.Max(1, Convert.ToInt32((finalValue - initialValue) / 50.0) - 1);
                while (initialValue < finalValue)
                {
                    if (cancellationToken.IsCancellationRequested)
                        break;

                    if ((initialValue + step) <= finalValue)
                        initialValue += step;
                    else
                        initialValue = finalValue;

                    currentValue = initialValue;

                    Device.BeginInvokeOnMainThread(() => (bindable as Label).Text = initialValue.ToString("C"));

                    await Task.Delay(50);
                }
            }
            else if (initialValue > finalValue)
            {
                var step = -Math.Max(1, Convert.ToInt32((initialValue - finalValue) / 50.0) - 1);
                while (initialValue > finalValue)
                {
                    if (cancellationToken.IsCancellationRequested)
                        break;

                    if ((initialValue + step) >= finalValue)
                        initialValue += step;
                    else
                        initialValue = finalValue;

                    currentValue = initialValue;

                    Device.BeginInvokeOnMainThread(() => (bindable as Label).Text = initialValue.ToString("C"));

                    await Task.Delay(50);
                }
            }
        }

        protected override void OnAttachedTo(Label bindable)
        {
            base.OnAttachedTo(bindable);
            AssociatedObject = bindable;

            if (bindable.BindingContext != null)
            {
                BindingContext = bindable.BindingContext;
            }

            bindable.BindingContextChanged += OnBindingContextChanged;
        }

        protected override void OnDetachingFrom(Label bindable)
        {
            base.OnDetachingFrom(bindable);
            bindable.BindingContextChanged -= OnBindingContextChanged;
            AssociatedObject = null;

            cancellationTokenSource.Dispose();
        }

        private void OnBindingContextChanged(object sender, EventArgs e)
        {
            OnBindingContextChanged();
        }

        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            BindingContext = AssociatedObject.BindingContext;
        }
    }
}

Could we pass listview item as command parameter on checkchanged event for Checkbox control

$
0
0

@Hello All,

I have below control in XAML, I want to pass Listview item as I change checkbox, I tried relative binding as below but I could get only CheckChangedEventArgs when event fired as command, I don't want to go under UI layer and stick to MVVM.. I read somewhere about switch that

You could use Behaviors to transform your Events into behaviors. Then you can use Commands and more importantly the CommandParameter with which you can specify the object that it is about. <

How could I specify object that it is about on CheckChanged Event

 <ListView
                        x:Name="InclusiveServiceList"
                        CachingStrategy="RecycleElement"
                        HeightRequest="{Binding TypeOfInclusiveServices.Count, Converter={StaticResource ItemsToHeightConverter}}"
                        ItemsSource="{Binding TypeOfInclusiveServices}">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="50" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <CheckBox
                                            Grid.Column="0"
                                            HeightRequest="40"                                            
                                            IsChecked="{Binding IsChecked, Mode=TwoWay}"
                                            WidthRequest="40">
                                            <CheckBox.Behaviors>
                                                <Behavior:EventToCommandBehavior
                                                    Command="{Binding BindingContext.AdditionalServicesInProcedureChargeCommand, Source={x:Reference InclusiveServiceList}}"
                                                    CommandParameter="{Binding Source={x:Reference InclusiveServiceList}, Path=BindingContext.ItemSource}"
                                                    EventName="CheckedChanged" />
                                            </CheckBox.Behaviors>
                                        </CheckBox>
                                        <Label
                                            Grid.Column="1"
                                            Text="{Binding Description}"
                                            VerticalOptions="Center" />
                                    </Grid>
                                </ViewCell>

                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>

Would like clarification for certificate and provisioning profile expiration dates

$
0
0

Hi, I'm not sure this is the right place to ask the question, but, . . .
I would like clarification on the expiration dates for apple certificates and provisioning profile.

Both have expiration dates associated with them.

My scenario is this:
Deploy an app to 10 devices through the app store with a certificates that expires in 12 months.
1. If the certificate is revoked prior to the 12 months, will the devices still be able to run the app for the remaining time prior to the certificate expiration?
2. Is the only effect of a revoked certification, the inability to build the app in Microsoft App Center?
3. If the provisioning file expires before the certificate expires, will the app on the devices still be able to run?
4. Is the only effect of an expired provisioning profile is the inability to build the app in Microsoft App Center?

I am getting ready to clean up a bunch of what I think are unnecessary or unused certificates and provisioning profiles, . . . just need to make sure deleting or removing something that has not expired won't break functionality in deployed apps.

Thanks

Android Changing Resolution & Control Scaling

$
0
0

Hi,

We built an app using Xamarin Forms and deployed it to our Samsung Note 8 test device. The GUI looks great but the minute we change the resolution the controls don't scale properly. However, when I close the app then relaunch it, the app looks perfect again.

Is there a method I can call in the SizeChanged event that will force the app to detect the new resolution and refresh how it scales the controls?

Thanks,
Nuno

Xamarin Forms Entry - Keyboard property not working in UWP

$
0
0

In Xaml Page,

In Android, it shows the numeric keyboard
but in Windows UWP app, entry is taking alphabets as well.

What is the suggested way to quickly develop Xamarin.Forms XML layouts?

$
0
0

It's taking me forever to layout a single XML screen without a live view of what the code represents. Change, run, try to remember, adjust a column, etc - a forever process.

I've seen options for "Gorilla Player", "Live (something)". Since I'm developing in Xamarin.Forms, my goal is to arrive at something decent for BOTH iOS and Android.

What is commonly being used or suggested? What are others using to speed this process? I'm on VS2019 (Windows) looking for dependable and long-term solution for rapid development.


TouchView | TouchImage | TouchFadeView | TouchColorView package

$
0
0

Hi all, let me introduce new plugin for Xamarin.Forms development.

https://github.com/AndreiMisiukevich/TouchEffect

This plugin allows developers to create UI-responsive controls/layouts with touch effect (fade control, change image source, change background color)

I will appreciate any feedback)

How to implement a simple CarouselView

$
0
0

Hello guys, I'm trying to use a simple CarouselView inside a layout.
I found that Xamarin.Forms.CarouselView (https://www.nuget.org/packages/Xamarin.Forms.CarouselView/2.3.0-pre1) is not present anymore on nuget.
So searching on the web I decided to use this one: https://github.com/alexrainman/CarouselView
This one is not working (for me) with a MasterDetailPage: the first page loaded (a Detail Page) shows nothing of the carousel (empty page), instead after i select another (or the same) page from the master the carousel works ok (but of course I need to open it in the first presented detail page too).
So, do you have some suggestions/other plugins to use?
Thanks,
Luca

Xamarin form pages stored on Azure Server

$
0
0

Hello, I'm trying to create an app for IOS and Android that loads created xaml pages from a server. There are several of these pages and it would be better that they are accessed by respective devices on load rather than stored locally on the devices as these forms are subject to changes and additional pages will be added frequently. All of the pages referenced will have cs file associated with them that will need to be accessed aswell.
The desired end result is an application that an loads has a list of all active pages/forms and when the user selects one of them, it will open, allow the user to fill it out and send it out.
Does anyone know if this is currently possible?

System.NullReferenceException when trying to save to database

$
0
0

Hi there,
This is my first attempt at creating an app using Xamarin Forms so apologies in advance if this is a simple fix, but I have searched in depth and cannot appear to find a solution to my error.

I am creating an SQLite database following the tutorial "Working with Local Db (SQLite) in Xamarin Forms" by Dheeraj Kumar G, with the only difference I have made is using my own input page with different inputs instead of the one he has created at 38.52 in the video. When I enter details in to my input page I get the following error - "System.NullReferenceException Object reference not set to an instance of an object", when I click the button to save my input to the database. The stack trace then points me to line 30 below which I have indicated with the arrow:

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BudgettingApp.Model;
using SQLite;

namespace BudgettingApp
{
    public class ExpenseDatabase
    {
        readonly SQLiteAsyncConnection database;
        public ExpenseDatabase(string dbPath)
        {
            database = new SQLiteAsyncConnection(dbPath);
            database.CreateTableAsync<ExpenseDetail>().Wait();
        }

        public Task<List<ExpenseDetail>> GetExpensesAsync()
        {
            return database.Table<ExpenseDetail>().ToListAsync();
        }

        public Task<ExpenseDetail> GetExpenseDetailAsync(int id)
        {
            return database.Table<ExpenseDetail>().Where(i => i.ExpenseID == id).FirstOrDefaultAsync();
        }

        public Task<int> SaveExpenseDetailAsync(ExpenseDetail expense)
        {
            if(expense.ExpenseID == 0) {                **## <-----------------**
                return database.InsertAsync(expense);
            }
            else {
                return database.UpdateAsync(expense);
            }
        }

        public Task<int> DeleteExpenseDetailAsync(ExpenseDetail expense)
        {
            return database.DeleteAsync(expense);
        }

    }
}

And then the second place Stacktrace points me to is line 21 on my Input c# page:

using System;
using System.Collections.Generic;
using BudgettingApp.Model;
using Xamarin.Forms;

namespace BudgettingApp.View
{
    public partial class OutgoingsPage : ContentPage
    {
        public OutgoingsPage()
        {
            InitializeComponent();
        }

        async void Save_Clicked(object sender, System.EventArgs e)
        {

            if (CategoryPicker.SelectedIndex != -1)
            {
                var newExpense = (ExpenseDetail)BindingContext;
                await App.Database.SaveExpenseDetailAsync(newExpense);  ## **   <----------------**
                await DisplayAlert("Expense saved!", "Tap to continue", "Ok");
            }
        }

        private void CategoryPicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            CategoryPicker.IsEnabled = true;
        }

        private void PaymentPicker_SelectedIndexChanged(object sender, EventArgs e)
        {
            PaymentPicker.IsEnabled = true;
        }
    }
}

I am not sure what I am looking for here, I have tried simplifying my input by removing the CategoryPickers etc but it did not help.

And finally here is the code for the input I am trying to save to:

    using System;
    using SQLite;

    namespace BudgettingApp.Model
    {
        public class ExpenseDetail
        {

            [PrimaryKey, AutoIncrement]
            //[Display(AutoGenerateField = false)]
            public int ExpenseID { get; set; }

            public string ExpenseName { get; set; }

            public string Category { get; set; }

            public DateTime Date { get; set; }

            public double Spent { get; set; }

            public string PaymentMethod { get; set; }

            public Boolean Recurring { get; set; }
        }

    }

I hope this post is okay, like I said it is my first attempt with Xamarin Forms so apologies if this is unclear, if any further code/explanation is required please let me know. Alternatively if there is a different method you
Thanks.

Global Exception Handling

$
0
0

Hi Everyone. I'm in my final submission of my Xamarin forms App. I want to handle Exceptions Globally in my Project. I tried this https://peterno.wordpress.com/2015/04/15/unhandled-exception-handling-in-ios-and-android-with-xamarin/ but it's not working.

    AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
        TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException;  

The above methods are not invoking when any exception raised. Any kind of help will be appreciated.

Is there some variable or function from which I can read the most recent build timestamp?

$
0
0

This could be useful in an "About" page.

Can any one please send me a source code for the description below , and please respond me asap

$
0
0

Hello,
I am working on a Xamarin.UWP app and I have to create a dynamic table on the basis of search box
for ex : I want to display employee detail then I am searching for a Name then all the record same name contain display to the table. also I can add a record , remove record and update record .also I have to implement first previous next last implementation from the data.
Can any one please help me out in this problem.


Shell: Replace the Root page of a Tab

$
0
0

I have a Shell with a few simple tabs defined as ShellContent items in AppShell.xaml. I want to dynamically change the Root page of one of the tabs.

Normally I would get the Navigation, then replace the root. I tried this by the NavigationStack has 1 item, but that item is null?

 async Task ReplaceRoot(Page page)
    {


        var root = Shell.Current.Navigation.NavigationStack[0];
        if (root != null)
        {
            Shell.Current.Navigation.InsertPageBefore(page, root);
        }
        else
        {
            await Shell.Current.Navigation.PushAsync(page, false);
        }

        await Shell.Current.Navigation.PopToRootAsync();
    }

Xamarin forms Map with Driving directions as like google maps.

$
0
0

Is this possible to create an application in xamarin forms with Maps with driving direction/ instructions?

I am developing an application with xamarin forms. In that i have to show in app map with driving directions and instructions. I searched in google but i did not get any such kind of applications. All are done in native applications. Somehow i should achieve this feature in Forms.

could anyone please give some suggestions to achieve this feature in xamarin forms.

Thanks in Advance.

Photo + Json In xamarin post webservice

$
0
0

Hi,

I want to add a json and photo(MultipartFormDataContent) in xamarin post webservice.

I know how to add json alone, but for adding image i didn't get any code.

I used many open sources, but got no luck.

Can someone please share source code which is working well?

Thanks in advance.

How to toggle between 2 models using a switch toggle

$
0
0

hello developers. i would to ask is it possible to toggle between 2 item source. for example: I have an Ui with switch toggle and when the user toggle the switch it will select and switch the item source binding to it

Xamarin Forms: Failed to launch the ios application on the device.

$
0
0

Getting the following message when installing xamarin forms ios app in physical ios device.

NSLocalizedRecoverySuggestion=Please try rebooting and reconnecting the device. (0xE8000022)., NSLocalizedFailureReason=Please try rebooting and reconnecting the device. (0xE8000022).}
warning MT1043: Failed to launch the application using the instruments service. Will try launching the app using gdb service.
Launching 'appname' on the device 'iPhone'
warning HE0030: Could not mount developer tools on 'iPhone': Could not locate device support files.
warning HE0031: Failed to mount developer tools on 'iPhone'.
warning HE0030: Could not mount developer tools on 'iPhone': Could not locate device support files.
warning HE0031: Failed to mount developer tools on 'iPhone'.
error MT1007: Failed to launch the application 'appname' on the device 'My iPhone': Failed to launch the application 'apname 'My iPhone': Invalid Service >Error (error: 0xe8000022). You can still launch the application manually by tapping on it.

I am using visual studio for mac version 7.7.3(build 43), iPhone 7(12.3.1) and xcode(Version 10.1 (10B61))

I have installed Xcode on mac, not iPhone. Is Xcode need to install on the iPhone for debugging the app?

I already found the same issue on here. Restarted iPhone, Mac and visual studio as per the solution on that thread, but that didn't help me.

Viewing all 91519 articles
Browse latest View live


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