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

emulator to connect private api (not local host) hosted within the local server(not as public ip).

$
0
0

I want to connect to the API hosted within our office Lan machine (not on public IP) in emulator (Android /iOS/ UWP).

Can you guys give me some idea.

using Genymotion emulator for android , simulator for iOS


Sending multiply files with POST

$
0
0

I'm trying to send many files from xamarin.forms over httpClient in one loop.
Api recieves 1 file and then all others comes as null.
Any advice? thanks!

Set a file's build action to 'Embedded resource' from app.xaml.cs

$
0
0

Hi All,
How can I set a file's build action to 'Embedded resource' from app.xaml.cs. If any one can throw some lights on this, that would be very helpful.

ContextAction MenuItem icon not showing in iOS

$
0
0

I'm developing PCL based solution using Xamarin.Forms. I added ContextAction to listview. I have delete MenuItem with trash icon in ContextActions. The trash icon not showing in iOS not platform.But in android its working fine. the iOS not support MenuItem icon?
My XAML code is

        <ViewCell.ContextActions>
                <MenuItem Text="Edit" x:Name="MenuEdit" />
                <MenuItem Clicked="OnDeleteMenu" Icon="dustbin.png" Text="Delete" IsDestructive="true" CommandParameter {Binding .}" />
    </ViewCell.ContextActions> 

i am using latest Xamarin.Forms.Please Anyone give the solution

Thanks,
Mahabaleshwar Hegde

App Center equivalent for Insights.Identify

$
0
0

Hello,

I'm working on changing a Xamarin.Forms app to use Microsoft App Center with the impending retirement of Xamarin Insights. So far it seems to be going well, though I do have a question about it.

In the app currently, we were using Insights.Identify to provide additional helpful information to us when looking at the Insights logs, such as the name of the user that has logged in, and the system that they're connecting to. I've been trying to find the equivalent for this in Microsoft App Center, but I didn't find anything in any of the documentation of the APIs that I was reviewing, and there doesn't seem to be any methods provided in the App Center NuGet packages that handle this same functionality.

Is this feature not implemented in App Center yet or is there some other way to provide this information in App Center? I tried creating a CustomProperties object, setting some Key/Value pairs in the object, and then calling AppCenter.SetCustomProperties, but that didn't seem to help. Would the best option right now be to just pass an IDictionary object with the key/value pairs I want to include in the log when making calls to methods like Crashes.TrackError or Analytics.TrackEvent?

Thanks in advance!

ContextAction MenuItem Icon is not displaying in IOS

$
0
0

Issue is in ListView i have ContextActions inside it i have menu button. & menu button has icon property.
That icon property only works with android Not with iOS.
Someone says the behaviour of the MenuItem that Xamarin.Forms has built-in is designed that the "Icon" property only works for Android. It only shows text by default on iOS.
But In order to work for IOS what is the solution.

how to rename images on iOS project?

$
0
0

Inside android project we have resources folder under resources folder it have 4 type of screen dpi size folder.but how to separate this images for iOS project inside Resources folder?

Package Microsoft.Net.Http was restored using .net framework 4.6.1 instead of the project framework

$
0
0

I am new at xamarin form and trying to add Microsoft.Net.Http Nuget Package in my .NetStandard type project but when I add Microsoft.Net.Http package in my project it raises some dependency issue.I am using visual studio 2017. Can anyone please help me to solve this problem.


Is it possible to get the Page that an element lives on?

$
0
0

Is there a quick way to get the root page of an element? Currently I'm doing a ((Page)Element.ParentView.ParentView.ParentView.ParentView.ParentView....
there must be a better way...

How can we call OnElementChanged Method multiple times from PCL(when using custom rendering)

$
0
0

I Have two grids(1.EmployeeList,2.EmployeeDetail) in one page and binding accordingly(Using IsVisible="{Binding isShowingEmpDetails}"). But, problem is I have to call OnElementChanged when i'm switching to second grid instead of page initialization because i have listview inside scrollview.

while debugging my ios app in visual studio it is showing th app is terminated???

$
0
0

how to resolve the issue while debugging the app is terminated(visual studio 2015 ios app)

Touch on Android and IPad tablets is not much sensitive for cross-platform Xamarin forms app.

$
0
0

It takes multiple touches to get the desired selection. For eg, If I want to open the new page, we have used if (this.AcquireTapLock()).To achieve it, Sometimes I have to tap on it 2-3 times.
In the app, we have also used some custom renderers to meet the requirements and made some Bindable properties of custom views.

Code snippet for Bindable properties -

public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(BetterImageButton), typeof(string), typeof(Image), string.Empty, BindingMode.TwoWay,
propertyChanged: (b, o, n) =>
{
(b as BetterImageButton).Image = n as string;
});

Does anyone have any idea how to optimize this?

Custom Renderer for Grid

$
0
0

Hi,

I want to build a custom rendere for Grid layout for iOS
How to build it, there is no GridRenderer

Build time error: "sequence contains no elements" on listview

$
0
0

Hi,

I have a problem with a master page of my app.

MasterPageItem

 public class MasterPageItem
    {
        public string Title { get; set; }

        public string IconSource { get; set; }
    }

ViewModel

public class MasterPageViewModel
    {
        public ObservableCollection<MasterPageItem> MenuItems { get; set; }
        public string UserName { get; set; }
        public string UserIconSource { get; set; }
    }

MasterPage

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage  xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:detail="clr-namespace:apptest.Views.Detail"
             xmlns:viewModels="clr-namespace:apptest.ViewModels;assembly=apptest"
             x:Class="apptest.Views.Master.MasterPage">
  <MasterDetailPage.Master>
    <ContentPage
                 x:Class="MasterDetailPageNavigation.MasterPage"
                 Padding="0,40,0,0"
                 Icon="slideout.png"
                 x:Name="Mpage">
      <ContentPage.BindingContext>
        <viewModels:MasterPageViewModel />
      </ContentPage.BindingContext>
      <ContentPage.Content>
        <StackLayout Orientation="Vertical">
          <Image Source="{Binding UserIconSource}"></Image>
          <Label Text="{Binding UserName}"></Label>
        </StackLayout>
        <StackLayout VerticalOptions="FillAndExpand">
          <ListView x:Name="MenuItemsListView" ItemsSource="{Binding MenuItems}" VerticalOptions="FillAndExpand" SeparatorVisibility="None" ItemSelected="OnSelection">
            <ListView.ItemTemplate>
              <DataTemplate>
                <ViewCell>
                  <StackLayout Orientation="Vertical">
                    <StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand">
                      <Image BindingContext="{Binding IconSource}" WidthRequest="30" HorizontalOptions="StartAndExpand"/>
                      <Label BindingContext="{Binding Title}" FontSize="20" VerticalTextAlignment="Center" HorizontalOptions="EndAndExpand"/>
                    </StackLayout>
                  </StackLayout>
                </ViewCell>
              </DataTemplate>
            </ListView.ItemTemplate>
          </ListView>
        </StackLayout>
      </ContentPage.Content>
    </ContentPage>
  </MasterDetailPage.Master>
  <MasterDetailPage.Detail>
    <NavigationPage>
      <x:Arguments>
        <detail:HomePage />
      </x:Arguments>
    </NavigationPage>
  </MasterDetailPage.Detail>
</MasterDetailPage>

In MasterPage.xaml.cs assign the BindingContext

BindingContext = new MasterPageViewModel
            {
                UserName = "username",
                UserIconSource = "icon.png",
                MenuItems = new ObservableCollection<MasterPageItem>()
                {
                    new MasterPageItem
                    {
                        Title = "Home",
                        IconSource = "icon.png"
                    },
            .......................................
                    new MasterPageItem
                    {
                        Title = "sponsor",
                        IconSource = "sponsor.png"
                    }
                }
            };

But when I build up my app i have an error

"Sequence contains no element" on listview.

Can anyone help me?

Thank you,

Simona

Update Localized Lables

$
0
0

Hi,
I've localized my app following this guide and implemented a picker to choose from languages for we i've made translations.
However, my lables only get updated, once I close and reopen the app.

Question: Can I update the labes more fluidly?


How Can i implement background process to notify user to sync unsynced information

$
0
0

I Xamarin forms app called Crew app that is used to to report flight information of the crew. But what i want is since there is no internet access in a flight time the crew can fill all the information offline and sync all the information to the server when connected to the internet. so my task is to ask the crew to sync the flight information she filled online immediately when the mobile is connected to the internet whenever she didn't open the app.

please help me this ! Xamarin Team.

Thanks for considering my question and i am looking forward for hearing from you.

async/await method crash web services response in android but same code work successfully in other

$
0
0

async/await method crash web services response in android but same code work successfully in window Phone and iOS apps in xamarin Native Appliation.

Xamarin Native Application (PCL)

I have created a Native application using portable Class libarary.

I request to REST API that gives the following response.

    {
    code: 200,
    status: "ok",
    message: "hello"
    }

my Portable class library code in xamarin.forms is

test.xaml.cs

    public class jsonResponseClass
    {
            public string code { get; set; }
            public string status { get; set; }
            public string message { get; set; }
    }
    public partial class test : ContentPage
    {
            public async void getDatas()
            {
                var cl = new HttpClient();
                var result = await cl.GetStringAsync("http://192.168.1.125/apps/jara/web/api/user/test");
                jsonResponseClass des = JsonConvert.DeserializeObject<jsonResponseClass>(result);
                lbl1.Text = des.code + " " + des.status + " " + des.message;
            }
            public test()
            {
                InitializeComponent();
                getDatas();
            }
    }

Main file in Portable class library (PCL)

App.cs

namespace NativeAppsWithWCF
{
    public class App : Application
    {
        public App()
        {
            MainPage = new test();
        }
        protected override void OnStart()
        {
            // Handle when your app starts
        }

        protected override void OnSleep()
        {
            // Handle when your app sleeps
        }

        protected override void OnResume()
        {
            // Handle when your app resumes
        }
    }
}

my visual studio solution explorer is

Using this above code I can successfully show output in iOS and Window Phone Apps.

But when i Run Android apps then crash the apps and not show output.

When i debug android program then cursor remove after this line.

var result = await
cl.GetStringAsync("http://192.168.1.125/apps/jara/web/api/user/test");

After this line i got an error and stop the execution of program.

See the screen after got error..

How to prevent this error ?

OAuth and all things Social.

$
0
0

I'm wanting to add the ability to log into various social media platforms and have stumbled across the Auth and Social plugins.

I noticed that the Social plugin is now quite old and was wondering if it still works, or if there is a more recent alternative.

The ReadMe states 'We'll demonstrate sharing using Facebook. In order to share with Facebook, you'll need to have created a Facebook app at https://developers.facebook.com/apps. Use the "Website with Facebook Login" integration and ensure you've added publish_stream in the "Extended Permissions" section.'

But the FB developer pages have changed and I can't find any reference to 'Website with Facebook Login' or 'Extended Permissions'. Maybe I'm looking in the wrong place ?

Any advice would be great.

DatePicker only certain Days

$
0
0

Hey!

I have one DatePicker, and I want that the user can only select Mondays and Saturdays. Is it possible?

Thanks

Realtime Xamarin Tesseract detection

$
0
0

I am attempting to use tesseract in Xamarin.Forms for text character recognition on images. On Android, I've implemented the logic using the steps below;

  1. Grab bitmaps of the TextureView.
  2. Convert bitmaps to black and white.
  3. Crop needed from the bitmap image
  4. Set tesseract image with cropped image

Currently facing memory issues and haven't got a way around it so far

Snippets below show the main functions of the code.

    public async void takeContinuousPhotos(){

        byte[] newBytes;
        byte[] bytes;

        while (ocrTextChosen == false){

            bytes = await CapturePhoto();

            newBytes = this.CropPhoto(bytes, new System.Drawing.Rectangle(40, view.Height / 2 - 200, view.Width - 40, 100), (view.Width - 40) * 2, 200);

            if (!_tesseract.Initialized)
            {
                await _tesseract.Init("eng");

                var result = await _tesseract.SetImage(new MemoryStream(newBytes));

                if (result)
                {
                    Device.BeginInvokeOnMainThread(() => {
                        this.ocrText.Text = this._tesseract.Text;
                    }); 
                    _tesseract.Clear();
                    bytes = new byte[0];
                    newBytes = new byte[0];
                }
            }
            else {
                var result = await _tesseract.SetImage(new MemoryStream(newBytes));
                if (result)
                {
                    Device.BeginInvokeOnMainThread(() => {
                        this.ocrText.Text = this._tesseract.Text;
                    });
                    _tesseract.Clear();
                    bytes = new byte[0];
                    newBytes = new byte[0];
                }
            }
        }
    }

    // Capture photo from stream
    public async Task<byte[]> CapturePhoto()
    {
        var ratio = ((decimal)Height) / Width;

        var blackwhiteBitmap = this.toGrayscale(liveView.Bitmap);

        var image = Bitmap.CreateBitmap(blackwhiteBitmap, 0, 0, blackwhiteBitmap.Width, (int)(blackwhiteBitmap.Width * ratio));

        byte[] imageBytes = null;

        using (var imageStream = new System.IO.MemoryStream())
        {
            await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 10, imageStream);
            image.Recycle();
            imageBytes = imageStream.ToArray();
            imageStream.Dispose();
        }

        image = null;
        return imageBytes;
    }

takeContinuousPhotos() is then run on the TextureView delegate method as shown below:

  public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
    {
        camera = Android.Hardware.Camera.Open();
        var parameters = camera.GetParameters();
        var aspect = ((decimal)height) / ((decimal)width);

        var previewSize = parameters.SupportedPreviewSizes
                                    .OrderBy(s => System.Math.Abs(s.Width / (decimal)s.Height - aspect))
                                    .First();

        parameters.SetPreviewSize(previewSize.Width, previewSize.Height);
        parameters.FocusMode = Android.Hardware.Camera.Parameters.FocusModeContinuousPicture;

        camera.SetParameters(parameters);
        camera.SetPreviewTexture(surface);
        StartCamera();

        Task.Run(() => {
            this.takeContinuousPhotos();                
        });
    }
Viewing all 58056 articles
Browse latest View live


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