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

Netflix style home page

$
0
0

Hi I'm extremely new to xamarin forms and I tremendously suck at coding layouts. I'm trying to figure out for hours now how to create a content page with some scrollviews that mimics something like this:

Any chance that you guys have samples or snippets to share for something like it?


How to Update label text from another class?

$
0
0

I know its a silly question but I am new in Xamarin.forms
I want to Update label text from another class in xamarin.forms. please guide me with a example. Thanks

get the imei number of the device

$
0
0

hi,
I want find the imei number of the device in xamarin forms .I have tryed the following solution but nothing is happen

This is serviceImei which implement the interface IServiceImei containg one function

And Mianpage having the following code

when i exceute this nothing is happen.
plz provide some suggestion.

Data after the Camera Capture always return Null

$
0
0

Good Day All

i am opening an Intent for Camera and I take a photo and when i save i want to get the saved file . i open my intent like this

                           Intent takePicture = new Intent(MediaStore.ActionImageCapture);
                           var  mPhotoUri = this.Activity.ContentResolver.Insert(MediaStore.Images.Media.ExternalContentUri, new ContentValues()); 
                            takePicture.PutExtra(MediaStore.ExtraOutput, mPhotoUri); 
                            StartActivityForResult(takePicture, 0); 

and in the Activity results i do this

       public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            if (requestCode == 0)
            {
                Uri u = null;
                if (hasImageCaptureBug())
                {
                    Java.IO.File fi = new Java.IO.File("/sdcard/tmp");  
                   u = Uri.Parse(Android.Provider.MediaStore.Images.Media.InsertImage(this.Activity.ContentResolver, fi.AbsolutePath, null, null)); 
                }
                else
                {
               **     u = data.Data; **
                }
      }

The intent gives me null

     u = data.Data;  

Thanks

Saving Picker SelectedItem to a table Binding

$
0
0

Hi! I am trying to save the selected item from the picker to a string which i can save in my sqlite table. I have used the MVVM and I dont know how to go any further. Here is my view model:

` public List Ingredients { get; set; }
public OilPickerViewModel()
{
Ingredients = GetIngredients().OrderBy(t => t.Value).ToList();
}

    public List<Ingredient> GetIngredients()
    {
        var ingredients = new List<Ingredient>()
        {
            new Ingredient(){Key = 1, Value = "Lavanda"},
            new Ingredient(){Key = 2, Value = "Peppermint"}
          };
        return ingredients;
    }
    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged([CallerMemberName] string name = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }
    private Ingredient _selectedIngredient1 { get; set; }
    public Ingredient SelectedIngredient1
    {
        get { return _selectedIngredient1; }
        set
        {
            if(_selectedIngredient1 != value)
            {
                _selectedIngredient1 = value;
                MyIngredient1 = _selectedIngredient1.Value;
            }
        }
    }
    private string myIngredient1 { get; set; }
    public string MyIngredient1
    {
        get { return myIngredient1; }
        set
        {
            if( myIngredient1 != value)
            {
                myIngredient1 = value;
                OnPropertyChanged();
            }
        }
    }`

Here it is what I have written in my view:
<Picker x:Name="ulei1Picker" Title="Alege primul ingredient" ItemsSource="{Binding Ingredients}" ItemDisplayBinding="{Binding Value}" SelectedItem="{Binding SelectedIngredient1}"/> <Button Text="Salveaza" x:Name="saveButton" Clicked="SaveButton_Clicked"/>

and my code-behind:

void SaveButton_Clicked(object sender, EventArgs e) { if ( ulei1Picker.SelectedItem == null ) { DisplayAlert("...");} else { Blend blend = new Blend() { Ulei1 = ulei1Picker.SelectedItem?.ToString() }}
I need the selected value from the picker to be saved to the Ulei1 string from the table but i just cant. How do I make this work?>!

How to stop firing the parent click event when click on child

$
0
0

I have BoxView inside the Stacklayout and Stacklayout has the click event which changes the color of BoxView.
I don't have any click event on BoxView. Though If I click on BoxView it fires StackLayout click event.
How can I stop firing parent click event when clicking on child ? (I don't want to do anything when click on BoxView)

share Authentication access token

$
0
0

Hi
I Have xamarin forms application, authenticate with asp.net membership and give accesstoken after authenticate.
In other platforms (ex silverlight, javascrip libs ....), this token access shared accross all requests to server (ex webclient,httpclient, image source request and ...) and all requests send it to server automaticaly
how can I share this token on xamarin forms for all requests?
I cant set cookies for all requests handly. because some of them like imagesource does not have any way to set it

How to auto resize control out srollview when scrolling

$
0
0

Hi guy, how to auto resize control out srollview when scrolling like contact detail in ios?
i design 2 stacklayout, one contain control need resize and the other contain scrollview

like this:

any ideas and solutions


NavigationPage TitleView Template

$
0
0

I want it to look like the photo on the right.
How can I make distances between them?

Xamarin.Essentials reports wrong Orientation on emulator

$
0
0

I've created this very little application that should tell me the orientation of the device using Xamarin.Essentials. It works fine on my Huawei P30 Pro Phone. Is this an emulator related problem?

The Emulators are the Pixel_3_q_10_0_-_api_29 and tablet_m-dpi_10_1in_pie_9_0

Here's the code:

using System.ComponentModel;
using Xamarin.Forms;

namespace OrientationProblem
{
    // Learn more about making custom code visible in the Xamarin.Forms previewer
    // by visiting https://aka.ms/xamarinforms-previewer
    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();

            Xamarin.Essentials.DeviceDisplay.MainDisplayInfoChanged += DeviceDisplay_MainDisplayInfoChanged;

            Orientation.Text = Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Orientation.ToString();
        }

        private void DeviceDisplay_MainDisplayInfoChanged(object sender, Xamarin.Essentials.DisplayInfoChangedEventArgs e)
        {
            Orientation.Text = e.DisplayInfo.Orientation.ToString();
        }
    }
}


<?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"
             x:Class="OrientationProblem.MainPage">

    <StackLayout>
        <!-- Place new controls here -->
        <Label x:Name="Orientation"
               HorizontalOptions="Center"
               VerticalOptions="CenterAndExpand"
               FontSize="Large"/>
    </StackLayout>

</ContentPage>

How to change DateTime AM PM format?

$
0
0
    DateTime Mor_Time = DateTime.Now;
            TimeSpan ts = new TimeSpan(10, 30, 0);
            Mor_Time  = Mor_Time .Date + ts;        // OutPut :  {5/22/2020 10:30:00 AM}

            DateTime Nigh_Time  = DateTime.Now;
            TimeSpan ts1 = new TimeSpan(10, 30, -1);
            Nigh_Time  = Nigh_Time.Date + ts1;      //OutPut :  {5/22/2020 10:30:00 AM}

I want to following Output format
Mor_Time = 5/22/2020 10:30:00 AM

Nigh_Time =5/22/2020 10:30:00 PM

What's the best and easiest way to implement PayPal in a Xamarin Forms App?

$
0
0

Hi guys,

I would like to allow paypal, what's a good and easy way to do in Xamarin Forms?

Best regards
Chris

App is not resuming, Refresh everytime with splash screen in physical device.

$
0
0

Hi
I am working an application which is working fine on simulator but app is not resume after installed ipa in physical device.
Tried with these in Appdelegate
public override void WillEnterForeground(UIApplication application)
{
base.WillEnterForeground(application);
}
public override void OnActivated(UIApplication uiApplication)
{
base.OnActivated(uiApplication);
}

Image Source always picking image from cache.

$
0
0

Hi , I am using Image control in Xamarin forms android app. Used at two places one on hamburger slider and another on a content page. i am resolving image from webapi and using the code below:
private void OnPresentedChanged(object sender, EventArgs e)
{

            ImgProfile.Source = new UriImageSource()
            {
                Uri = new Uri(Constants.ProfilePicUrl),
                CachingEnabled = true,
                CacheValidity = new TimeSpan(5,0,0,0)
            };
        }

I tried aove code with both the conditions CachingEnabled = true/false . Here is what I observed:

  1. CachingEnabled = False : Each time the image control flickers and reloads the image. I can see a time gap of second or two between image reload from web url. Similary in the slider menu.
  2. CachingEnabled = true: My image control keeps on displaying the cached version even if the url has newer/different image, as its profile page and user can change his/her profile image N times a day.

So #1 solves my problem but the flickering part is annoying. Also please note , profile image is taken and uploaded from camera so there no way of uploading a customized image with lesser size to eliminate the delay..

I hope , my problem is clear to you guys.

Is there a way to know if user rated app?

$
0
0

Hello,
I implemented rating functionalities for both iOS and Android. In iOS, I used SKStoreReviewController and in Android, users directed to the Playstore.
Is there a way to know if user rated the app? If yes how can I know the point(or stars) user rated my app?

I want to show rating pop-ups to user if user rated less than 4 stars to my app in earlier version. Is this possible in both platforms?


FreshMVVM - Tabbed Navigation ViewIsAppearing not getting fired on initial tab click

$
0
0

I have implemented tabbed navigation using FreshMVVM. When my app launches, I could notice that the 'ViewIsAppearing' method is getting invoked for all the tabs. If I switch to one tab, the 'ViewIsAppearing' in its ViewModel is not getting called. But if go to some other tab and switch back to this same tab, then it works. i.e. 'ViewIsAppearing' is not getting invoked in the initial tab change click. How do I make it invoke in the first attempt itself.
I have come across a github issue similar to this. Just adding for reference
github.com/xamarin/Xamarin.Forms/issues/3855

VS2019 the specified path file name or both are too long error !

$
0
0

Hi everyone !

I'm archiving to publish ios from my Xamarin forms project, but I get an error ;

I've put my project on a shorter path to fix this error. (In :C). But , I keep getting errors. Because I think archive files are being created in a very different place. I couldn't solve this problem. How do I move the archive files? Ultimately these files in AppData. Wouldn't it be a mistake to relocate them?

My project location

My project archive location

What should I do. Please help me !

Unable to use Toast, Activity Indicatior

$
0
0

I have a simple Xamarin Form app with a .net standard project and Android Project. I am facing a problem since day of development is that , I am unable to pull Toast and Activity Indicator on form. I dont know why. I tried almost all major plugins as well.

Here's my login code where I want to see a toast. I have used UserDialogs, Forms.Plugin etc and now using Plugin.Toast.

  protected void BtnLogin_Clicked(object sender, EventArgs e)

        {
            try
            {
                CrossToastPopUp.Current.ShowToastMessage("Message"); // Plugin.Toast package
                var userName = TxtUserName.Text.Trim();
                var password = TxtPassword.Text.Trim();
                userController.DoLogin(userName, password);
            }
            catch (NullReferenceException)
            {
                DisplayAlert("Mobile # and Password, both are required.", "JCAA", "OK");

            }
            catch (Exception ex)
            {
                DisplayAlert(ex.Message, "JCAA", "OK");
                Crashes.TrackError(ex);
            }


        }

GZip Decompression/Deserialisation from Mobile application side

$
0
0

Hi,

I am working on Xamarin forms and My app consume WEB API which used GZIP to compress data.
How can I decompress this.
HttpClientHandler httpHandler = new HttpClientHandler()
{
AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate
};

But this is not working. Please help me with the correct solution for this

Is there any Xamarin.Forms Camera2 sample that actually works, including all the features I need?

$
0
0

Hi,

for the past 12 months I've been looking into upgrading my Xamarin.Forms app that uses the deprecated Camera API in the android renderer to the new Camera2 API. I've tried many samples, but none of them were exactly what I needed. Some didn't work at all, some did, but were missing key features.

What do I need?
Pretty much a clone of the native camera app minus the camera settings. I need a camera view that is showing the photo preview, can take photos (take photo button) and has some additional information overlayed on top of the camera preview (just some TextViews).

The best of the samples I've found (the UNIT-23 sample) still wasn't as reliable as I'd like. It worked, however, sometimes it would just crash for no apparent reason and the stack trace wasn't very useful. The other ones either had fewer features implemented or were only Xamarin.Android examples.

The samples I've tried were (I can't post links, so here are the repository names):

  • The official Xamarin Camera2 Basic sample
  • The official Xamarin Camera2 Raw sample
  • UNIT-23/Xam-Android-Camera2-Sample
  • vtserej/Camera2Forms
  • HofmaDresu/AndroidCamera2Sample
  • thekeviv/CameraFeed

I've also searched this forum, Xamarin.Forms docs, StackOverflow, and Google with no 100% working results.

Is there an example that could help me achieve the thing I want?
Thank you

Viewing all 89864 articles
Browse latest View live


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