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

InApp-Billing

$
0
0

Hey folks,
as I'm taking huge steps to release our app, I'm now at the point where I have to implement a payment function. And I was curious if anyone here used the InApp-Billing Components from the components store and has a few tips for me.

Since those are platform packages I guess the best way to use them is via DependencyService.

As the instructions from the components are good, maybe someone found a few hints for Forms.

Greetings


Toast for IOS

$
0
0

Using Xamarin forms to implement toast message.
I have implemented successfully in simple hello world application and works fine (android and iOS).
when I implement the same in my project toast message is not displaying message (iOS). no error showing

I was stuck for 2 days..

Error executing task XamlCTask: Task does not have property "DebugType" defined

$
0
0

Hi I'm getting this error ("Error executing task XamlCTask: Task does not have property "DebugType" defined") all the time now with an app of mine when I run on Android, a couple of cleans, rebuild and restarts makes it go a way for a while but it's soon back again. Driving me nuts, does someone know how to solve this?

Delay response from GeoLocator.GetGeopositionAsync() in UWP

$
0
0

Hi,

I am trying to get current location of my device in UWP. Using GeoLocator.GetGeopositionAsync() taking time (2-5 minutes) to provide current location of mobile in uwp. Please suggest solutions to get quick result

Defect in Forms Frame Outline on Android...

$
0
0

I am having trouble RESETTING the Outline of a Frame on Android. A simple app with click a button change the color of the outline of the frame. The same code works just fine on iOS. On Android, the frame outline remains the original color.

MVVM Xamarin Forms Command Binding not working

$
0
0

Hello Everyone,
I am new to this forum, but I encountered a rather annoying problem with Xamarin.Forms.
The thing is I cannot Bind a Command to a button.

I can see that the constructor of my ViewModel runs, however when i press the button, the command never gets executed.

I set the Command property through XAML btw.
But if I set the command property through code behind, then it works. That is quite strange and frustrating.

I get no errors, and when I debug the button, I can see that the Command property is NULL. It is as if I got ignores my binding.

This is the XAML code :
http://pastebin.com/Cj97fatp

This is The ViewModel code :
http://pastebin.com/yuLRdbrN

Thanks in advance

Attribute "imageAspectRatioAdjust" already defined with incompatible format

$
0
0

For a day, I am facing problem when I try to build my Droid project and the above error arises. This happened after I updated my plugins and Xamarin Forms to 2.5.x.xxxx. I have made sure all projects have same Xamarin Forms version but nothing has changed. Any help from other developers? I understand I am not the first one facing the issue.
Complete error:
Severity Code Description Project File Line Suppression State
Error {Project.Path}XXXX.Droid\obj\Debug\lp\78\jl\res\values\values.xml:1: error: Attribute "imageAspectRatioAdjust" already defined with incompatible format

Is WindowsAzure implemented in Xamarin's all platforms?

$
0
0

We are using DownloadToByteArrayAsync function in Xamarin portable project, it is running fine in Windows.UWP project, but we are getting error in iOS & Android. projects.

CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx");
            CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
            CloudFileShare share = fileClient.GetShareReference("samplesileshare");
            CloudFileDirectory rootDir = share.GetRootDirectoryReference();
            CloudFileDirectory sampleDir = rootDir.GetDirectoryReference("Dir_1");
            CloudFile file = sampleDir.GetFileReference(filename);
            int status = await file.DownloadToByteArrayAsync(filedata, 0);
            label1.Text = "Success!";

Error details: Microsoft.WindowsAzure.Storage.StorageException: An error occurred while sending the request ---> System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: ConnectFailure (Connection refused)


Refresh a GridView

$
0
0

Hi,

I have a GridView and each tile contains user-specific details hence I would like a refresh on this view if the user's details had to change while using the app. I've tried the following approach by adding a refresh for one of my tiles but this doesn't work. Is there any other way to achieve this for the whole gridView?

My xaml

     <Grid x:Name="cardBalance" >
            <Image Source="GiftCard.jpg" HorizontalOptions="Fill" VerticalOptions="Fill" Aspect="AspectFill" Grid.Row="0" Grid.Column="0" x:Name="CardImage"/>
            <Image Source="store2.jpg" HorizontalOptions="Fill" VerticalOptions="Fill" Aspect="AspectFill" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"/>
            <Image Source="GridTrans.jpg" HorizontalOptions="Fill" VerticalOptions="Fill" Aspect="AspectFill" Grid.Row="0" Grid.Column="1" />
            <Image Source="ProfileBg2.JPG" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Aspect="AspectFill" Grid.Row="2" Grid.Column="0" />
            <Image Source="gridSettings.JPG" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Aspect="AspectFill" Grid.Row="2" Grid.Column="1" />

        <ScrollView Grid.Row="0" Grid.Column="0">
            <ListView x:Name="CardBalance" HasUnevenRows="True" Grid.Row="0" Grid.Column="0" VerticalOptions="Fill" IsPullToRefreshEnabled="True" Refreshing="CardBalance_Refreshing">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Vertical"
                                 HorizontalOptions="FillAndExpand"
                                 VerticalOptions="FillAndExpand"
                                 x:Name="Layout">
                                <Frame>

                                    <StackLayout Orientation="Horizontal"  HorizontalOptions="FillAndExpand">
                                        <StackLayout Orientation="Vertical"  HorizontalOptions="FillAndExpand">
                                            <Label Text="Card Balance:" TextColor="Black"/>
                                            <Label Text="{Binding Balance}" TextColor="Black"/>
                                        </StackLayout>
                                        <StackLayout Orientation="Vertical"  HorizontalOptions="EndAndExpand">
                                            <Image Source="{Binding CustomerLogo}" HeightRequest="60" WidthRequest="60"></Image>
                                        </StackLayout>
                                    </StackLayout>
                                </Frame>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </ScrollView>

        <Label Text=" Tap to view detail" TextColor="Gainsboro" FontSize="14"  FontAttributes="Bold" HorizontalTextAlignment="Start" VerticalTextAlignment="End" Grid.Row="0" Grid.Column="0" x:Name="CardTile"/>
        <Label Text=" Tap to view all card balances" TextColor="#64676b" FontAttributes="Bold" HorizontalTextAlignment="Start" VerticalTextAlignment="End" Grid.Row="0" Grid.Column="0" x:Name="MultipleCards"/>


        <Label Text=" Transactions" TextColor="White" FontAttributes="Bold" HorizontalTextAlignment="Start" VerticalTextAlignment="End" Grid.Row="0" Grid.Column="1"  x:Name="TransactionTile"/>
        <Label Text=" Promotions" TextColor="White" FontSize="30" FontAttributes="Bold" HorizontalTextAlignment="Start" VerticalTextAlignment="End" Grid.Row="1" Grid.Column="0"  Grid.ColumnSpan="2"  x:Name="PromoTile"/>
        <Label Text=" My Profile" TextColor="White" FontAttributes="Bold" HorizontalTextAlignment="Start" VerticalTextAlignment="End" Grid.Row="2" Grid.Column="0"  x:Name="ProfileTile" />
        <Label Text=" Settings" TextColor="White" FontAttributes="Bold" HorizontalTextAlignment="Start" VerticalTextAlignment="End" Grid.Row="2" Grid.Column="1"   x:Name="SettingsTile"/>

        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="2*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="1*" />
        </Grid.ColumnDefinitions>
    </Grid>

Xaml.cs (The refresh code)
private void CardBalance_Refreshing(object sender, EventArgs e)
{
LoadCards();
CardBalance.IsRefreshing = false;
}``

Is it possible to Customize the scroll bar of Scroll view

$
0
0

I want to Customize scroll bar view as shown in attached image in xamarin.Forms. Please let me know is this possible with custom render or any other alternate way to do that.

Change search bar text field background color?

$
0
0

I'm working on an iOS custom renderer to change the background color of the text field within the search bar control in my Xamarin.Forms project but can't figure it out. Here's how it's looking so far:

class CustomSearchBarRenderer : SearchBarRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e)
        {
            base.OnElementChanged(e);

            UISearchBar bar = (UISearchBar)this.Control;

            foreach (var view in bar.Subviews)
            {
                view.BackgroundColor = UIColor.Blue;
                view.TintColor = UIColor.Green;
            }

            bar.Layer.BorderWidth = 0;
        }
    }

There is no effect on the background color though... Any suggestions?

Xam.Media.Plugin camera icon hides in landcsape orientation on Orientation lock:OFF (IOS)

$
0
0

Note - Project is cross platform and developed in forms.

When iPhone orientation is locked (orientation lock : ON) this plugin works fine. In case of iPhone orientation is unlocked (orientation lock : OFF), camera plugin starts giving the problem. If I rotate iPhone from Portrait to Landscape and back to Portrait, then the previous screen turned up from back and camera controls seems to be disappear. But if i rotate the the iPhone twice or thrice, it seems to be work fine again. So the thing is it doesn't work fine when iPhone Orientation is unlocked. Please refer the attached image.
@JamesMontemagno do you have any idea sir?

Xam.Plugin.Media v3.1.1
Xamarin.forms v2.0.5782

Thanks

ForceUpdateSize listview Issue on IOS

$
0
0

Hi,

I have a custom listview using custom viewcells with radio buttons. On clicking of each of the radio buttons the listview dynamically resizes its height to hide/show a comment box.
On using ForceUpdateSize in IOS platform, the listview performance slows down rapidly on clicking the radio buttons. The app eventually hangs and stops responding.

Is there an alternative solution to use instead of ForceUpdateSize to dynamically expand the listview row at runtime?

Thanks

Error: socket might closed or timeout, read ret: -1

$
0
0

Error: socket might closed or timeout, read ret: -1

Hello guys,
I am getting the above error when I connect to device blutooth, this only happens when I am going to print a variable inside For

Could someone tell me how I can handle this problem?

Follow the code I'm using

foreach (BluetoothDevice d in bthD)
{
if (d.Name.ToString().Trim() == "MPT-III")
{
Java.Util.UUID UUID = Java.Util.UUID.FromString("00001101-0000-1000-8000-00805F9B34FB");
BluetoothSocket s = null;
s = d.CreateRfcommSocketToServiceRecord(UUID);

                    for (int i = 0; i < sparArray.Count; i++)
                    {

                        s = d.CreateInsecureRfcommSocketToServiceRecord(UUID);

                        string agroquimico = mitens[i].ToString();
                        clslogin login = new clslogin();

                        int agroquimico_id = int.Parse(agroquimico.Substring(0, agroquimico.IndexOf(" |")));
                        string pega_apaga = agroquimico.Substring(0, agroquimico.IndexOf(" / "));
                        pega_dose = agroquimico.Replace(pega_apaga, "").Replace(" / ", "");
                        pega_dose = pega_dose.Substring(0, pega_dose.IndexOf("--"));

                        byte[] buffer = System.Text.Encoding.GetEncoding(0).GetBytes(agroquimico + "\n");


                        IntPtr createRfcommSocket = JNIEnv.GetMethodID(d.Class.Handle, "createRfcommSocket", "(I)Landroid/bluetooth/BluetoothSocket;");
                        IntPtr _socket = JNIEnv.CallObjectMethod(d.Handle, createRfcommSocket, new Android.Runtime.JValue(1));
                        s = Java.Lang.Object.GetObject<BluetoothSocket>(_socket, JniHandleOwnership.TransferLocalRef);

                        bth1.CancelDiscovery();

                        try
                        {

                            s.Connect();
                            s.OutputStream.Write(buffer, 0, buffer.Length);
                            s.Close();
                        }
                        catch
                        {
                            //Toast.MakeText(this, "Failed to connect: " + connectException.Message, ToastLength.Short).Show();
                            Toast.MakeText(this, "Failed to connect", ToastLength.Short).Show();
                        }

                    }
                  }
                }

How to add hyperlink for Label in Xamarin.Forms.

$
0
0

Hi,

   FormattedString  t = new FormattedString();

   t.Spans.Add(new Span() { Text = "About my Self\n\n" });
   t.Spans.Add(new Span() { Text = "1. My website\n\n" }); 
   t.Spans.Add(new Span() { Text = "2. My  Linkedin profile\n\n" }); 
   t.Spans.Add(new Span() { Text = "3. Twitter\n\n" }); 

I have a Text like above, I am able to set hyperlink whole text but I want to set hyperlink for website and Linkedin words with some URL

How can I set hyperlink for particular word in Paragraph for Label

Please help me on that. Thanks in advance.


Unable to install PDF.js NugetPackage https://www.nuget.org/packages/PDF.js/ in xamarin project.

$
0
0

I tried adding Nugget package PDF.js https://www.nuget.org/packages/PDF.js/ in project.
But I am getting following error:

Could not install package 'PDF.js 1.3.91'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v7.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I tried to install NuGet package with android version greater than 7.1, but same above error is coming.

Please guide.
Thanks in advance.

ToolbarItem with Image and text

$
0
0

Hi,

Is there a way to display ToolbarItem with image and text below the image in Xamarin.Forms.

Thanks,

Segment control rendering in Android

$
0
0

How to write segment control rendering in Anroid.

Cannot write to USB OTG mass storage device

$
0
0

Hi All,

I'm on an Android 5.0 device where a usb mass storage is mounted at "/storage/usbotg" via USB OTG cable.
I can access this folder with a file browser app that allows me to read/write files. Unfortunately from my app I only have read access to that folder. Please note that I set the write external storage permission as I'm able to write to device storage.

I post the following code as reference:

string Root = "/storage/usbotg";
string[] Dirs = Directory.GetDirectories(root);

string NewFolder = Path.Combine(Root, "NewFolder");
Directory.CreateDirectory(NewFolder);

This gives me an exception on the last line (but I'm able to list subdirectories in Dirs)

System.UnauthorizedAccessException
Access to the path "/storage/usbotg/NewFolder" is denied.

If I use:

string Root = "/storage/emulated/0";

everything is working fine and the "NewFolder" is created.

What I'm missing? How can I write to that folder?

I'm using Xamarin.Forms 2.5.0

Thanks for your help

Searchbar with infinite loading

$
0
0

Hi guys, i have a searchbar and a listview with infiniteloading (loadmore), when i type in the searchbar raise the TextChanged events where i refresh my list with new query. The event raise on every typed characters and that's cause too much element added on the list (not only filtered elements).

private void Handle_TextChanged(object sender, Xamarin.Forms.TextChangedEventArgs e)
        {
            ListaNewsView.BeginRefresh();
            ((NewsViewModel)this.BindingContext).Search();
            ListaNewsView.EndRefresh();
        }

public void Search()
        {
            PageNumber = 0;
            ListaNews.Clear();
            LoadMore();
        }

public async void LoadMore()
        {
            if (IsLoading)
                return;
            IsLoading = true;

            PageNumber++;

            var items = await App.RestService.GetListaNewsAsync(PageNumber, PageSize, SearchedText);

            foreach (var item in items)
            {
                ListaNews.Add(item);
            }

            IsLoading = false;
        }

    public class InfiniteListView : ListView
        {
            /// <summary>
            /// Respresents the command that is fired to ask the view model to load additional data bound collection.
            /// </summary>
            public static readonly BindableProperty LoadMoreCommandProperty = BindableProperty.Create(nameof(LoadMoreCommandProperty), typeof(ICommand), typeof(InfiniteListView), default(ICommand));
            /// <summary>
            /// Gets or sets the command binding that is called whenever the listview is getting near the bottomn of the list, and therefore requiress more data to be loaded.
            /// </summary>
            public ICommand LoadMoreCommand
            {
                get { return (ICommand)GetValue(LoadMoreCommandProperty); }
                set { SetValue(LoadMoreCommandProperty, value); }
            }

            /// <summary>
            /// Creates a new instance of a <see cref="InfiniteListView" />
            /// </summary>
            public InfiniteListView()
            {
                ItemAppearing += InfiniteListView_ItemAppearing;
            }


            void InfiniteListView_ItemAppearing(object sender, ItemVisibilityEventArgs e)
            {
                var items = ItemsSource as IList;

                if (items != null && e.Item == items[items.Count - 1])
                {
                    if (LoadMoreCommand != null && LoadMoreCommand.CanExecute(null))
                        LoadMoreCommand.Execute(null);
                }

            }
        }
Viewing all 58056 articles
Browse latest View live


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