Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

How to change the scrollbar color of a listview

$
0
0

Hi, I want to change the vertical scrollbar color of a list view in xamarin forms. How can i do this.

Please help me...


How to give gesturedetector for circle ?

$
0
0

Hii community
i need a solution or suggestion for Increase or decrease the values of circle like slider

How to do..
if any please suggest
thanks

DatePicker Binding Not Binding

$
0
0

Hi, So I'm still new in Xamarin Forms and has been asked to develop an app wherein it keeps track of schedules of the business. Such as when the business started, the business ended and so on.

But before I explain what's happening here's the code for the view

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="xamarin.com/schemas/2014/forms"
             xmlns:x="schemas.microsoft.com/winfx/2009/xaml"
             x:Class=""
             xmlns:local=""
             Title="Lock" Icon="">
    <ContentPage.Content>
        <StackLayout>
            <StackLayout Padding="10">
                <TableView Intent="Data">
                    <TableRoot>
                        <TableSection Title="Schedule">
                            <ViewCell>
                                <StackLayout Orientation="Horizontal" Padding="20,0">
                                    <Label Text="Sched Start" HorizontalOptions="StartAndExpand" VerticalOptions="Center" FontSize="Small"></Label>
                                    <DatePicker Format="MM/dd/yyyy" Date="{Binding SchedStartDate, Mode=TwoWay}" HorizontalOptions="EndAndExpand"></DatePicker>
                                    <TimePicker HorizontalOptions="EndAndExpand"></TimePicker>
                                </StackLayout>
                            </ViewCell>

                            <ViewCell>
                                <StackLayout Orientation="Horizontal" Padding="20,0">
                                    <DatePicker Format="MM/dd/yyyy" Date="{Binding SchedEndDate, Mode=TwoWay}" HorizontalOptions="EndAndExpand"></DatePicker>
                                    <TimePicker HorizontalOptions="EndAndExpand"></TimePicker>
                                </StackLayout>
                            </ViewCell>
                        </TableSection>
                    </TableRoot>
                </TableView>
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

This one is the code for the ViewModel

    public DateTime? SchedStartDate
            {
                get
                {
                    return this.schedStartDate;
                }

                set
                {
                    if (value != this.schedStartDate)
                    {
                        this.schedStartDate = value;
                        OnPropertyChanged();
                    }
                }
            }

            public DateTime? SchedEndDate
            {
                get
                {
                    return this.schedEndDate;
                }

                set
                {
                    if (value != this.schedEndDate)
                    {
                        this.schedEndDate = value;
                        OnPropertyChanged();
                    }
                }
            }

And I'm calling this in the code behind in OnAppearing() method.

        public async void GetLock (int ID)
                {
                    var result = await MyHttpRequest.GetSchedule(ID);

                    SchedStartDate = DateTime.Now;
                    SchedEndDate = DateTime.Now;
                    ActualStartDate = DateTime.Now;
                    ActualEndDate = DateTime.Now;
        }

So what's happening is whenever I run the app the first DatePicker, the one binded to "SchedStartDate" gets populated with the Data from the DB.
But the second one goes to the default.

Things I did:
1. I removed the first datepicker and the second datepicker gets the data from the DB.
2. 100% sure that the data is not default since I checked the data when I debugged.
3. Tried to use the same Binding Field for both DatePickers, but only the first one gets populated with the DB Data.
4. Tried to set the 2 variables to DateTime and it worked, but I would need to have null?

Note: This page is inside the TabbedPage, I doubt that's the issue, but just in case.

Hopefully someone can help me figure this out or did I miss something in the documentation, please let me know.
Any help is appreciated. :smiley:

Custom control text changed event, throwing time out exception when hitting api

$
0
0

Hi All,

I am using a custom autocomplete view control to show the available options in listview when user enter any character. On the text changed event while hitting the api for that particular character, i am getting timeout exception whereas i am getting response through that api in spinner. I am using text changed event of this custom control for my code.
No other api also not working in that particular event.
I have tested the autocomplete text is working fine when i populated it with json data and i am write code behind UI in my project.

This how i am hitting he api :

var serviceResponse = new ServiceResponse<List> { IsSuccess = false };

            #region HttpWebRequest

            var request = (HttpWebRequest)WebRequest.Create(Constants.ServiceBaseUrl  + searchString + "/" + type);
            request.ContentType = "application/json; charset=UTF-8";
            request.Method = "GET";
            request.Headers["Authorization"] = string.Empty;
            //request.Headers["Authorization"] = Settings.SessionId;

            IAsyncResult resultResponse = request.BeginGetResponse(null, null);
            resultResponse.AsyncWaitHandle.WaitOne(30000); 

            using (HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(resultResponse) as HttpWebResponse)
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    serviceResponse.IsSuccess = true;
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    {
                        var content = reader.ReadToEnd();
                        if (content != "")
                            serviceResponse.Data = (List<GeneralKeyValService>)Newtonsoft.Json.JsonConvert.DeserializeObject(content, typeof(List<GeneralKeyValService>));
                    }
                }
                else
                {
                    serviceResponse.IsSuccess = false;
                    serviceResponse.Message = response.StatusDescription;
                }
                response.Dispose();

Anyone knows why its not working and what and where i am missing anything?

Android Pie Not Getting Current Location in App Background Sleep Mode

$
0
0

Hi Friends,

I want to get current location, when app went into sleep mode or Background.Currently i am using > Plugin.Geolocator.CrossGeolocator.Current DLL in App OnSleep() , But Its Working Till Android 8.1 but Android Pie Not updating current Location Values.. How to Achieve in Android Pie?

My Code:
var minute = TimeSpan.FromSeconds(30);
Device.StartTimer(minute, () =>
{
await Task.Run(async () =>
{
TimeSpan t = TimeSpan.FromSeconds(10);
var locator = Plugin.Geolocator.CrossGeolocator.Current;
locator.DesiredAccuracy = 5;
var position = await locator.GetPositionAsync(timeout: t);
//API Method
});
});

Detect if Image not visible to user | ScrollView | COntentPage

$
0
0

Hi.
I Have 1 problem.

I have ContentPage.

In the start of this page i have Image element and another content in stack layout etc...
All content inside Scroll View

Now I want to catch, when user scroll down, and when IMAGE NO DISPLAY to user.

What is th e best way to catch that user doesn`t see the Image???

How take a SkiaSharp SKData and write out a pdf?

$
0
0

Our app uses SkiaSharp and Xamarin Forms to create sketches. We can take a completed sketch and write it out as a jpg.
SKData skData = surface.Snapshot().Encode(); using (Stream stream = File.Open(fileout, FileMode.OpenOrCreate, System.IO.FileAccess.Write, FileShare.ReadWrite)) { skData.SaveTo(stream); }

How do I write it out as a pdf?

One step is to create an SKDocument like this:
SKDocument skDocument = SKDocument.CreatePdf(SKWStream, dpi);
How do I turn the SKData into an SKWStream?

Thanks for having a look at this.

How design a camera APP?

$
0
0

I want to design a camera app.Any suggestion please?


I need to help Multipart for to send a image to server

$
0
0

Hi! My first time here
I need to help to send a image to server with Multipart.
I tried but without sucess. A tutorial ?

iOS app crashes when saving camera photo, but only in app store version

$
0
0

I have an iOS app that works fine on my iPad in debug mode. When I archive it and install it from XCode in ad-hoc mode it also works fine.

When I take the same archive and sign it for the app store and download it from there it crashes when I try and save a photo taken with the camera.

My crash log is showing

libsystem_kernel.dylib
__abort_with_payload
libsystem_kernel.dylib
abort_with_payload
TCC
__CRASHING_DUE_TO_PRIVACY_VIOLATION__
TCC
__TCCAccessRequest_block_invoke.77
TCC
__tccd_send_message_block_invoke
libxpc.dylib
_xpc_connection_reply_callout

Clearly, that suggests a privacy violation, but I am requesting permission from the app and granting it as a user. Any ideas what could be causing this and why it only affects the App Store release?

ZXing Scanner Camera is not activating in UWP and WP 8.1

$
0
0

I am using the example code from the ZXing page .
Details are :
Operating System : Windows 10 Pro N
Visual Studio Enterprise 2015
Xamarin.Forms 2.3.1..114
ZXing.Net.Mobile 2.1.47
ZXing.Net.Mobile.Forms 2.1.4.7

I am using below code

btnScan.Clicked+=async(sender,e)=>{
var scanPage = new ZXingScannerPage ();
await Navigation.PushModalAsync (scanPage);
scanPage.OnScanResult += (result) => 
{
    scanPage.IsScanning = false; 
    Device.BeginInvokeOnMainThread (async () => 
    {
        await Navigation.PopModalAsync ();        
        await DisplayAlert("Scanned Barcode", result.Text, "OK");
    });
};

}

Also I have added the below line in the MainPage.xml file of the UWP project just before LoadApplication method call
ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingBarcodeImageViewRenderer.Init();

Also I have provided access to the WebCam from the application manifest.

  1. When I run the application in Debug or Release mode in the emulator then it opens the scanner but small black/white /red /green square comes and computer webcam is not accessed.
  2. When I run it as windows 10 app then nothing comes, only blank screen comes.
  3. When I run it in the real windows 10 mobile, then scanner opens but camera doesn't opens, the white screen with red line opens and camera doesn't activates.

The same thing happens with WIndows 8.1 also.

Any help would be deeply appreciated. I have wasted lot of time to explore the internet used almost every combination. If anyone have the solution please please provide me.

Note:
The above code works fine for Android and I am able to scan the bar code and QR code.

Not able to get byte array from Signature pad image , throwing exception

$
0
0

Not able to get byte array from Signature pad image , throwing exception

public static byte[] ReadFully(Stream input)
{
using (MemoryStream ms = new MemoryStream())
{
input.CopyTo(ms);
return ms.ToArray();
}

    }

How to allow-back dispatch of TouchEvents on a ViewGroup

$
0
0

I have a custom ScrollViewRenderer with OnInterceptTouchEvent returning false on the Move event, therefore taking ownership of TouchEvents over its child.
How can I - at some point - reverse this behavior and dispatch the TouchEvents to its child.
In my case I'd like to allow dispatch on Up (release) in order for the child to receive that event.

Hope that's clear enough, thank you.

Missing an assembly reference

$
0
0

In VS2015 xamarin i have added a jar file as binding library and added that as a reference to my project. but while using the header file
using com.Example.tscdll; , it gives me the following error. The Type or namespace name example does not exist in the namespace com.
the jar file i have added is for TSC bluetooth mobile printer

Shadow Effect sample appears not to work

$
0
0

Hi, I have downloaded the xamarin-forms-samples from github. Using the the xamarin-forms-samples-master\Effects\ShadowEffect\EffectsDemo.sln and running this on the Android emulator produces no visible effect whatsoever.

Am I doing something wrong? or is this sample just outdated?


MessengingCentre Subscribe running twice although message was only send once.

$
0
0

// In my PCL

public ConstructorVM()
        {
            MessagingCenter.Unsubscribe<UploadMessage>(this, "Upload");
            MessagingCenter.Subscribe<UploadMessage>(this, "Upload", message =>
            {
             //my codes

            });
        }

//In one of my listener in android platform

 var message = new UploadMessage();
 MessagingCenter.Send(message, "Upload");

Hi guys, as mentioned in the title, my subscribe codes ran twice even though my MessagingCenter send only ran once. When i first call the the ConstructorVM page, the codes work as per normal Messagingcenter only ran once, but however when I ran it leave and enter the ConstructorVM page again, it would run twice, it seems as though the subscription from the previous instance wasn't unsubscribed.

Any idea on how can I tackle this problem?

Deleting the Media file

$
0
0

I'm using the xam.plugin.Media library and I've been using the multimedia plug-in to capture the photo from an Android device using XF. I have noticed that the files are stored in the specified directory. My question is: how can I delete these files from storage after use? Why do they keep appearing when you put it in an img tag?

before it worked for me but under the update of xamarin form I stop working I would appreciate your help

Xamarin Android App works fine on Oreo and above versions of android, but crashes otherwise

$
0
0

I'm calling the following activity from a fragment (using Android.Support.V4.App) to upload a file from device

        var intent = new Intent();
        intent.SetType("*/*");
        intent.SetAction(Intent.ActionGetContent);
        Activity.StartActivityForResult(Intent.CreateChooser(intent, "Select Files"), 0);

When I select a file, the code successfully returns to

        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
           base.OnActivityResult(requestCode, resultCode, data);

           if (resultCode == Result.Ok) // File Attachment
           {
              ICursor returnCursor = ContentResolver.Query(uri, null, null, null, null);
              int nameIndex = returnCursor.GetColumnIndex(OpenableColumns.DisplayName);

              returnCursor.MoveToFirst();

              var fileName = returnCursor.GetString(nameIndex);

              ViewModel.Files.Add(new FileModel()
              {
                 FileName = fileName,
                 FileBytes = HelperClasses.FileStreamHelper.ReadFully(stream)
              });
           }    
        }

The code successfully completes the OnActivityResult method but immediately after that the app crashes with the following error

        --- End of managed Java.Lang.ArrayIndexOutOfBoundsException stack trace ---
        java.lang.ArrayIndexOutOfBoundsException: length=8; index=-1
            at java.util.Arrays$ArrayList.get(Arrays.java:3854)
            at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:349)
            at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:405)
            at android.widget.ArrayAdapter.getView(ArrayAdapter.java:371)
            at android.widget.Spinner.makeView(Spinner.java:702)
            at android.widget.Spinner.layout(Spinner.java:650)
            at android.widget.Spinner.onLayout(Spinner.java:612)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
            at android.widget.ScrollView.onLayout(ScrollView.java:1535)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1795)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1167)
            at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:852)
            at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:871)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
            at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
            at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
            at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
            at com.android.internal.policy.DecorView.onLayout(DecorView.java:724)
            at android.view.View.layout(View.java:17523)
            at android.view.ViewGroup.layout(ViewGroup.java:5612)
            at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2342)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2069)
            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)
            at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301)
            at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
            at android.view.Choreographer.doCallbacks(Choreographer.java:683)
            at android.view.Choreographer.doFrame(Choreographer.java:619)
            at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
            at android.os.Handler.handleCallback(Handler.java:751)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:154)
            at android.app.ActivityThread.main(ActivityThread.java:6077)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

Note that the code works on Android Oreo and above version, but fails on a Nougat device.

Bluetooth classic example with Xamarin for UWP (RFCOMM)

$
0
0

Hi all;

I am looking for any examples or clues for RFCOMM server (bluetooth classic) sample for Xamarin UWP, any help for me?

Can't Access CrossPushNotification

$
0
0

I have installed Xam.Plugin.PushNotification . And my project is shared Project but still unable to access CrossPushNotification, PushNotificationService..
Any suggestion please......

Viewing all 204402 articles
Browse latest View live