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

Last Cell of ListView Cutoff?

$
0
0

I have this Xaml definition here and no matter how much padding to the bottom I put, the ListView doesn't move up. Half of the last cell in the ListView is cutoff, and I am not sure why. This is what I am seeing:


How to make Bluetooth read faster?

$
0
0

I have an app, that gets streaming PCm data from a Bluetooth connection. That data is then written into the Audiotrack player, that than plays the song parts. The problem is that after a while the player starts to stutter (repeat the last couple of bytes), before loading the new ones in. I believe this is caused by the Bluetooth reading method, because if I play it only directly on hosting phone, it plays normal. But on here it starts to write these errors, saying that Audiotrack is underrun, and after too many of these, it will just stop playing. My code is here:

public void Read()
    {
        System.Threading.Tasks.Task.Run(() =>
        {
            int _bufferSize;
            AudioTrack _output;

            _bufferSize = AudioTrack.GetMinBufferSize(44100, ChannelOut.Stereo, Android.Media.Encoding.Pcm16bit);
            _output = new AudioTrack(Android.Media.Stream.Music, 44100, ChannelOut.Stereo, Android.Media.Encoding.Pcm16bit,
                _bufferSize, AudioTrackMode.Stream);
            _output.Play();

            byte[] myReadBuffer = new byte[_bufferSize*2];

            while (true)
            {
                try
                {
                    mmInStream.Read(myReadBuffer, 0, myReadBuffer.Length);
                    _output.Write(myReadBuffer, 0, myReadBuffer.Length);
                }
                catch (System.IO.IOException ex)
                {
                    System.Diagnostics.Debug.WriteLine("Input stream was disconnected", ex);
                }
            }
        }).ConfigureAwait(false);
    }

ENTRY Hide keyboard Xamarin

$
0
0

I moved from xamarin.android to xamarin.forms, don't know why, just I think more support is here, but no. I'm trying to make Entry, that will be still focused, but without showing keyboard. I have inbuilt barcode scanner with keyboard input but i was finding a lot and there is no tutorial, how can i get throught that.

There's a problem, that I don't really understand connection between Project and Project.android. In xamarin.android there was command EditText.TextInput=0 and all was done, but now, i really don't know how to make it.

There is a lot of tutorials, helps, etc. but I tried most of it, and nothing works. Have just this:

<Entry x:Name="dataInput" Completed="OnBarcodeReaded"/>

private void OnBarcodeReaded(object sender, EventArgs args)
        {
            if (!string.IsNullOrWhiteSpace(dataInput.Text))
            {
                DisplayAlert("Input", dataInput.Text, "OK");
                dataInput.Text = string.Empty;
            }
        } 

Please, does anyone know, how to pass throught it ?
Some advice how works Projectname and Projectname.Android. Or how to read serial input, may there will be output directly from scanner. Thanks a looot :)

Async UI event handlers - So now all my event handlers are re-entrant?

$
0
0

Question - We have implemented async/await in our UI event handlers, now we have the problem that if users mash on the UI they can re-enter our event handlers before they have completed because there are await's in the event handlers.

Now we have the problem of having to either display a busy indicator over the entire UI surface blocking all user input or implementing a flag that has to be checked by all UI event handlers.

There seems to be no other way to deal with this issue, specifically nothing baked into the Xamarin Forms API??

Xamarin froms Forms horizontal list view with buttons to move the dates to right, left

$
0
0

This is result of what I need to implement. If anyone had contact with something similar ,let me know

Calling PickPhotoAsync() method changes parameters to Utmdev.Xf.Shape.Content.Shape elements

$
0
0

I have a list of Utmdev.Xf.Shape.Content.Shape elements in an object on my page.
When I call CrossMedia.Current.PickPhotoAsync() method this leads to changes in all parameters of the elements.
Can anyone help me with this problem?

how get user detail by token

$
0
0

i need get the users details when i send the token from urlencoded

Shell Navigation Bar Gradient

$
0
0

Is it possible through custom rendering to add a gradient to a shell's navigation bar?


Google Drive Rest API

$
0
0

Hi, I am trying to implement a feature in my app where the user logs in on their Google account and can upload/download to their Drive.
I have a functioning solution using Android.Gms.Drive, and Android.Gms.Auth.Api.SignIn, but, unsurprisingly this only works for android and with the deprication of Google Drive Android API, this will need to be migrated to the rest api anyway.

The question I have is, are there any good tutorials for implementing this? The one I find aren't intended for Xamarin, along with the fact that I am uncertain which libraries are best for the situation.

Any suggestions are appreciated.
Thank you for your time and assistance.

Saving a database in Google Drive

$
0
0

Hello, I am using the NuGet Pacage Plugin.GoogleClient to log in the users google accaunts. My problem is that after users sign in with their google accaunts and I receive their accaunts data but I don't know how to use google drive for saving a database in my app's folder in google drive. I want to do this in my MainPage, but after reading so many articles about this I still can't find a working solution. If someone has already done it in his project and knows how it works please help me.

how to bind DatePicker.Date

$
0
0

Any idea how to bind the datepicker, here is my code which is not working:

DateTime strDateTime=Convert.ToDateTime("01/14/2020");
tbDate.Date = strDateTime;

xaml code:

<DatePicker x:Name="tbDate" FontSize="22" MinimumDate="1/1/2018" StyleId="tbDate" MaximumDate="12/31/2020" DateSelected="MainDatePicker_DateSelected" HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand" WidthRequest="170" HeightRequest="50" Grid.Row="3" Grid.Column="1" Format="MM/dd/yyyy"

Closing browser without user interaction

$
0
0

I have a scenario where I need to open a browser to remove user cookies for logging out. So the process is:

  1. Open browser (Chrome CustomTab or SFSafariView depending on OS) and point it towards my URL to delete cookies.
  2. Send the user back to the mobile app login screen.

Where I'm having an issue is step 2. How do I go about closing/minimizing the browser without requiring user interaction? The only thing I have found so far is to run System.Diagnostics.Process.GetCurrentProcess().Kill(); which closes the entire app, but I have seen comments online that doing this might cause the app to get rejected by Google and/or Apple.

Any ideas on how I can solve this?

Azure App Service AD Authentication

$
0
0

I have a Xamarin Forms App that authenticates users against Azure AD using MSAL.NET and it works. This application also needs to access a .NET Core Web API running in Azure App Service and uses Azure AD for authentication. I was able to create a service principal for this app service, my mobile app and provide API access. Also, I set the API scope in code and I was able to get a token. But my requests to the App Service using this token fail with 401. Anyone has any thoughts?

How to fit the height of CollectionView when it is wrapped by ScrollView?

$
0
0

Hi to everyone!
I do not know if is a problem or a misunderstanding by me (maybe the second one) but I can not success to set any height size to my CollectionView.

I am starting to use Xamarin and I was trying to use the CollectionView object when I realized that the height of this View is very large (and other View Objects had an addecuate size, for example Label Views).
The height is more or less like the height Page.
Firstly I think that was a problem with the inside objects. I tried with strings and custom objects without success.
After a lot of tests, I tried with an empty CollectionView (with the BackgroundColor set in LightBlue) and I realized that my problem is not in the collectionView objects, but is in the CollectionView object itself.
When I was trying to reproduce the problem to publish it here I realized that the CollectionView was fitting its own size to the page size (the height is still very big but less than the height Page).
So, finally, I checked my code and found that the CollectionView is inside a StackLayout and this StackLayout is in a ScrollView.
I mean:

    <ScrollView>
       <StackLayout>
          <CollectionView>
          </CollectionView>
       </StackLayout>        
    </ScrollView>

When I wrap the StackLayout in a ScrollView, the CollectionView height increase (I didn't measure it, but the height is more or less like the height page).

This height is very large and I didn't find an option to change its height.

I am using the latest stable version of Xamarin (3.6.0.344457). But I also checked the latest preliminar version (4.0.0.394984-pre) without success.
To test the program I am using an emulator with Android 9.0 (Api 28) and my own smartphone (Nexus 5X with Android 8.1, Api 27).

To reproduce the problem I created a new Mobile Application (Xamarin.Forms) project, select a Shell template and, in ItemDetailPage.xaml, I added the ScrollView, two labels and the CollectionView.
This is the full code of ItemDetailPage.xaml with my own modifications:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http: //xamarin.com/schemas/2014/forms"
<!-- Ok, I added a space between "http:" and "//" in this two urls because I can not publish urls in your forum due to I am a new user. Sorry! -->
             xmlns:x="http: //schemas.microsoft.com/winfx/2009/xaml"
             x:Class="XamarinTest.Views.ItemDetailPage"
             Title="{Binding Title}">

    <ScrollView>
        <StackLayout Spacing="20" Padding="15">
            <Label Text="Text:" FontSize="Medium" />
            <Label Text="{Binding Item.Text}" FontSize="Small"/>
            <Label Text="Description:" FontSize="Medium" />
            <Label Text="{Binding Item.Description}" FontSize="Small"/>

            <Label Text="CollectionView:"></Label>
            <CollectionView BackgroundColor="LightBlue">

            </CollectionView>
            <Label Text="End CollectionView"></Label>
        </StackLayout>        
    </ScrollView>

</ContentPage>

I only want a CollectionView that it only has the necessary height, the enough to wrap it's own children.

Thanks in advance!

How to set the height of a grid to fill the screen and keep the width proportional?

$
0
0

Hi all,
I've created a page in XAML where I have a grid inside a scroll view. The grid contains buttons that represents the map of a site. The objective is to set the height of the grid to fill the available space of the screen and keep the width proportional to the height. The grid is essentially a rectangle so the width of the grid will be inevitably out of the screen, but thanks to the scrollview I will be able to scroll horizontally. If you have an idea how I can achieve this it will be appreciated. Also, if you have another way to achieve this without a grid or a scrollview feel free to share it. Thank you.


ServerCertificateValidationCallback not getting called

$
0
0

Something must have changed recently in an update as I am no longer able to bypass certificate validation using the ServerCertificateValidationCallback delegate. Previously I had a build configuration that auto-enabled the "Managed" HttpClient implementation and a certificate callback so that we could use the 10.0.0.3 local address to talk to a local server for development purposes. This allowed us to use a local CA certificate that is not in Android emulator's trusted root.

It has been a little while since I needed to do this type of server side debugging so switching to the Local build configuration no longer seems to work. I never get to the callback and instead get a validation error. Anyone know if something specifically changed to be able to bypass the cert verification?

EXCEPTION:
Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
at /Users/builder/jenkins/workspace/archive-mono/2019-06/android/release/external/boringssl/ssl/handshake_client.c:1132

at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00048] in <9e820d206a8d4177b453df9c2fa8d1cc>:0
at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in <9e820d206a8d4177b453df9c2fa8d1cc>:0
at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool)
at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <9e820d206a8d4177b453df9c2fa8d1cc>:0
at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in <9e820d206a8d4177b453df9c2fa8d1cc>:0

Local Build Config in Android Project:
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Local|AnyCPU'"> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\Local</OutputPath> <DefineConstants>DEBUG;__LOCAL__;</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <AndroidLinkMode>None</AndroidLinkMode> <AndroidSupportedAbis /> <AndroidHttpClientHandlerType>System.Net.Http.HttpClientHandler</AndroidHttpClientHandlerType> <AndroidLinkTool>r8</AndroidLinkTool> <AndroidDexTool>d8</AndroidDexTool> <AndroidEnableMultiDex>false</AndroidEnableMultiDex> <AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent> <LangVersion>latest</LangVersion> <AndroidTlsProvider> </AndroidTlsProvider> </PropertyGroup>

MainActivity OnCreate:
//if __ LOCAL __
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
//endif

Dynamic Grid

$
0
0

Hello and sorry for my English! I'm developing a cross-platform app in xamarin and I'm newbie to this!
I fill a grid dynamically with data but not all data show in one page!
In my scenario there will be a grid that will fill with 3 columns and min-rows 6, max-rows 8! but in one page i can see only the 5 first rows and nothing else! How can I make it more responsive or what can I do to show all data.
Using scrollView didn't help at all. The only think i managed with this was to have 5 pages with one content of the grid, again without the last row.

Any help would be useful. Thank you in advanve

how to bind username in label

$
0
0

Hi Xamarin forum

how can I display my username on

Nevermind guys I all ready figure it out

Animators may only be run on Looper threads

$
0
0

i've searching the same error on google but didnt find solution yet.

my xamarin forms apps implement refit library to call rest api and here my viewmodel for login page view.

using Acr.UserDialogs;
using Newtonsoft.Json;
using System;
using System.Threading.Tasks;
using DAFTAR.Models;
using DAFTAR.Views;
using Xamarin.Essentials;
using Xamarin.Forms;
using Xamarin.Forms.Internals;

namespace DAFTAR.ViewModels.Forms
{
    /// <summary>
    /// ViewModel for sign-up page.
    /// </summary>
    [Preserve(AllMembers = true)]
    public class SignUpPageViewModel : LoginViewModel
    {
        #region Fields

        private string name;

        private string password;

        private string confirmPassword;

        #endregion
        IUserDialogs _userDialogs = UserDialogs.Instance;
        #region Constructor

        /// <summary>
        /// Initializes a new instance for the <see cref="SignUpPageViewModel" /> class.
        /// </summary>
        public SignUpPageViewModel()
        {
            this.LoginCommand = new Command(this.LoginClicked);
            this.SignUpCommand = new Command(this.SignUpClicked);
        }

        #endregion

        #region Property

        /// <summary>
        /// Gets or sets the property that bounds with an entry that gets the name from user in the Sign Up page.
        /// </summary>
        public string Name
        {
            get
            {
                return this.name;
            }

            set
            {
                if (this.name == value)
                {
                    return;
                }

                this.name = value;
                //this.NotifyPropertyChanged();
            }
        }

        /// <summary>
        /// Gets or sets the property that bounds with an entry that gets the password from users in the Sign Up page.
        /// </summary>
        public string Password
        {
            get
            {
                return this.password;
            }

            set
            {
                if (this.password == value)
                {
                    return;
                }

                this.password = value;
                //this.NotifyPropertyChanged();
            }
        }

        /// <summary>
        /// Gets or sets the property that bounds with an entry that gets the password confirmation from users in the Sign Up page.
        /// </summary>
        public string ConfirmPassword
        {
            get
            {
                return this.confirmPassword;
            }

            set
            {
                if (this.confirmPassword == value)
                {
                    return;
                }

                this.confirmPassword = value;
               // this.NotifyPropertyChanged();
            }
        }

       //public StudentResult SR { get; set; } 
       //public StudentResult sr { get { return SR; } set { SR = value; } }

        #endregion

        #region Command

        /// <summary>
        /// Gets or sets the command that is executed when the Log In button is clicked.
        /// </summary>
        public Command LoginCommand { get; set; }

        /// <summary>
        /// Gets or sets the command that is executed when the Sign Up button is clicked.
        /// </summary>
        public Command SignUpCommand { get; set; }

        #endregion

        #region Methods

        /// <summary>
        /// Invoked when the Log in button is clicked.
        /// </summary>
        /// <param name="obj">The Object</param>
        private void LoginClicked(object obj)
        {
            // Do something
        }

        /// <summary>
        /// Invoked when the Sign Up button is clicked.
        /// </summary>
        /// <param name="obj">The Object</param>
        /// 

        private async void SignUpClicked(object obj)
        {
            // Do something
            try
            {
                StudentResult sr = new StudentResult();
                //App.Current.MainPage.DisplayAlert("Testing", this.Name,"Ok" );
                if (string.IsNullOrEmpty(this.Name))
                {
                    _userDialogs.Toast("Please key in your ID", TimeSpan.FromSeconds(5));
                }
                else
                {

                    sr = await CallVerify(Name).ConfigureAwait(false);

                    if (sr.apiStatus == true)
                    {

                        await SecureStorage.SetAsync("icNo", this.Name).ConfigureAwait(false);
                        await Task.Delay(500).ConfigureAwait(false);
                        Application.Current.MainPage = new MainPage();
                    }
                    else
                    {
                        _userDialogs.Toast(sr.apiMessage, TimeSpan.FromSeconds(10));
                    }

                }
            } catch (Exception e)
            {
                _userDialogs.Toast(e.Message, TimeSpan.FromSeconds(10)); // debug

            }
        }

        private async Task<StudentResult> CallVerify(string IcNo)
        {

            //var GetIcNo = await SecureStorage.GetAsync(IcNo).ConfigureAwait(false);
            var rsps = await ApiManager.Verify(IcNo).ConfigureAwait(false);
            StudentResult srs = new StudentResult();

            if (rsps.IsSuccessStatusCode)
            {
                var response = await rsps.Content.ReadAsStringAsync().ConfigureAwait(false);
                srs = await Task.Run(() => JsonConvert.DeserializeObject<StudentResult>(response)).ConfigureAwait(false);

                //ImageBase64 = await Task.Run(() => JsonConvert.DeserializeObject<DaftarPelajar>(response).qrStudentId).ConfigureAwait(true);
                //_userDialogs.Toast(imageBase64, TimeSpan.FromSeconds(10));
                //studentName = dp.studentName;
                //OnPropertyChanged("DaftarPelajar");
                //MakeUps = new ObservableCollection<MakeUp>(json);

            }
            else
            {
                await PageDialog.AlertAsync("Unable to get data", "Error", "Ok").ConfigureAwait(false);

            }
            return srs;

        }

        #endregion
    }
}

Command execute the async task. if i disable(comment code) async task call on command SingnUpClick, i can go to main page but Looper error will throw after enabled it back.

RelativeLayout Problem

$
0
0

Hi
I have a problem with pages which use RelativeLayout. These pages have transparent background (which allow to display partially page loded before) and content which is not a full page. Everything is perfect when mobile is in portrait mode but when I turn it into landscape mode suddenly the strap appear at the bottom.
This is my file code:



    <ScrollView RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.25}"
                     RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.25}"
                     RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.5}"
                     RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.5}"
                     BackgroundColor="Beige"
                     >
        <Image Source="HomeIcon.jpg" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"/>
    </ScrollView>
</RelativeLayout>

The image01 shows what it looks like when everything works and the Image02 when there is some strap at the bottom. I tried to switch it off by using: Shell.TabBarIsVisible="False", and many other ways but nothing worked so far.

Can you please help me with this?

Regards

Viewing all 77050 articles
Browse latest View live


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