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

For User Control ListView binding in XAML not working as expected

$
0
0

Hi All,

I have created the usercontrol for Listview control. Used the below code in code behind for bind. it's working fine.

XAML page
<controls:UCListView x:Name="listview1"/>
.CS page
listview1.ListViewBind = ViewModel.Bindlistview1;

Now, I want to bind the control from View model page(Used MVVM Pattern). Tried below code but not working. kindly let me know anyone how to achieve this.

XAML page
<controls:UCListView x:Name="listview1" ItemsSource="{Binding Bindlistview1,Mode=TwoWay}"/>

User Control page code

public UCListView()
        {
            try
            {
                InitializeComponent();
                BindingContext = this;
            }
            catch
            {
            }

        }

public static readonly BindableProperty ListSourceProperty =
           BindableProperty.Create<UCListView, ObservableCollection<Helpdesk>>(p => p.ListViewBind, new ObservableCollection<Helpdesk>());

        public ObservableCollection<Helpdesk> ListViewBind
        {
            get { return (ObservableCollection<Helpdesk>)GetValue(ListSourceProperty); }
            set { SetValue(ListSourceProperty, value); }
        }

Regards,
Ashwin C


Is there any way to remove navigationpage default back "

$
0
0

hello ,
i am trying to remove navigation page back button with NavigationPage.SetHasNavigationBar(some page, true) but its not working.

How is the xamel syntax to load a byte[] image?

$
0
0

Hello together,

How can I write this line of Code in xamel? is there a way?

byte[] image;

new Image {Source = ImageSource.FromStream(() => new MemoryStream (image))};

Thanks for your help.

Using protobuf (with/without XLabs)

$
0
0

Hello everyone!

I want to start using protobuf with Xamarin Forms, there is some nuget package
https://www.nuget.org/packages/protobuf-net/

I can install it to Droid project, but I cannot install it to PCL project, this error I get:
Could not install package 'protobuf-net [... version etc ...]'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', 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.

How can I fix it and start to use protobuf with Xamarin Forms?
Thanks!

What is this? A Progress Bar for ants?

$
0
0

It needs to be atleast... 3 times bigger. I'm trying to show the users progress. This will show the percentage the user has completed. Is there any way, other than custom renderers that I can use to increase the width and height of the ProgressBar? HeightRequest and MinimumHeightRequest seems to do nothing and Scale increases the size but somehow makes the progress bar jump out of the grid it resides in, like its scaling everything including the position.

xamarin forms gridview design

$
0
0

i have completed app in android studio now i wants to makes for ios and i choose xamarin forms for it because i wants to shifted my android studio project into xamarin forms but i have found issues with design layouts my problem is i wants to design gridview as i attached photo please see my attached file.
How could i create gridview like native i wants to create 5 boxes with 3 columns in it.

async await behaving strangely in Android & iOS

$
0
0

Hi,

I am using async, await to update UI on button click to indicate user that some progress is going on and I am showing loading panel onclick of button. Below is my code:

Android:

async void loginButtonGesture_Tapped(object sender, EventArgs e)
{
    try
    {
    DependencyService.Get<Idevice>().StartLoading();
        await AsyncUpdateStatus();
    }
}


private async Task AsyncUpdateStatus()
{
            try
            {
                await Task.Run(() =>
                {
                      //Device.BeginInvokeOnMainThread is used in places to stop loading the screen
                });
           }
}

iOS:

async void loginButtonGesture_Tapped(object sender, EventArgs e)
    {
        try
        {
        DependencyService.Get<Idevice>().StartLoading();
            await Task.Delay(40); //Required for iOS, otherwise it loading panel is keep on running
            await AsyncUpdateStatus();
        }
    }


    private async Task AsyncUpdateStatus()
    {
                try
                {

                     //await Task.Run(() => Enabling new thread also not working
                    //Device.BeginInvokeOnMainThread is used in places to stop loading the screen

               }
    }

In iOS, adding some delay and commenting Task.Run only worked in iOS. Why its so? But if I do this for Android then, Android loading panel is not working.

Windows phone button image size.

$
0
0

Hi,

I'm using Forms to build an application for iOS, Droid and WP. I need to have a button with an image on it, and adding a

<Button Image="back.png" x:Name="BackButton" />

produces the desired result. Except, in Windows Phone, the image is really tiny, like 1/4 of the size on Android or iOS. I have fought with getting the size adjusted for more than a day now, and have not been able to resolve the problem. That's why I am asking you.

Does anyone know how to set the size of an image in a button in Windows Phone?


image slideshow on xamarin.forms

$
0
0

Hi,
I want to use an image slideshow in my application but I can't find any control or component to use in xamarin.forms.
Does anyone know how I should do this?

Square List Xamarin.Forms (Grid binding ViewModel?)

$
0
0

Hey,

I want to know how to create a "Square list" (with Grid probably) dynamically.

For example, i want to have this thing:

I really insist on "dynamically", because i want to add/delete row/column like i want.

I work with Xamarin.forms and Binding (viewmodel)

Can you help me ?

PopToRoot function is not cleared the page title in Android

$
0
0

Hi,

I am facing the below issue when i use the PopToRoot function to navigate to root root page. This issue is in Android only.

Issue:
1. I am in 'Page1' and when i click on 'next' button it redirected to 'Page2'
2. Provided information in 'Page2' and redirected to 'Page3'
3. on Command called PopToRoot in page3 and it redirected to Page 1 (this is expected).
4. tap on a new tab and come back to the previous tab (page1). Here you will see the page title of 'Page3

Button Image Size

$
0
0

Hi

Attached images to a button in windows phone 8,1 / UWP are rendered tiny. Is this a known bug ? How can this be solved ?

Regards

Label not showing string "Date" and "From" on screen when set in Text property

$
0
0

I have use below 2 labels on xamarin forms xaml.

But on iOS simulator I see text as below.

=> Expected Delivery
=> Ship

Expected outcome should be,
=> Expected Delivery Date:
=> Ship From:

I did not get the reason why "Date:" and "From:" are missing.

Front Camera Image Rotating

$
0
0

Is there any way to detect if the image is taken by front camera in xamarin forms, because I am uploading an image through front camera rotates upside down.
I have read about Exif but dont know how to implement it in xamarin forms. Please tell me if any of you have encountered the problem.

RedirectURI in Xamarin.Auth

$
0
0

Hi everyone,
I'm fairly new into mobile and Xamarin.
I'm creating an app that can retrieve user's data from Trakt.tv.
What value should I use for redirectUrl so after authentication completed, it will redirect user to a view/page?

Here is my code:

var context = Forms.Context;
        var baseAddress = ConfigHelper.TraktAPIURL;
        var auth = new OAuth2Authenticator(
                clientId: ConfigHelper.ClientID,
                redirectUrl: new Uri(ConfigHelper.RedirectURI),
                scope: "",
                authorizeUrl: new Uri(baseAddress + "/oauth/authorize?response_type=code")
                );
      auth.AllowCancel = true;
      auth.Completed += AuthenticateCompleted;
      auth.Error += AuthenticateError;
      var intent = auth.GetUI(context);
      context.StartActivity(intent);

When I try with "urn:ietf:wg:oauth:2.0:oob", it won't get to Completed event, but just showing a page with json object like below:

A query about the Acr.XamForms.SignaturePad control.

$
0
0

Hi

I am trying to use the signature control on a XAML Page.  (Acr.XamForms.SignaturePad) After going through the samples (XAML and MVVC) I observed that the XAML sample does not have a method to instantiate the control and write the image to a stream. So I wrote my code as below.

public partial class AddSignature : ContentPage
{

    private readonly ISignatureService signatureService;


    public AddSignature()
    {
        InitializeComponent();
        signatureService = DependencyService.Get<ISignatureService>();
    }

public async void btnSave_Clicked(object sender, EventArgs args)
{

       // var signpad = new SignaturePadView();
        var imageType = "Acr.XamForms.SignaturePad.ImageFormatType.Png";
        var fileName = String.Format(FILE_FORMAT, DateTime.Now, imageType.ToString().ToLower());
        long fileSize;

        IFile file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);

        try
        {
            var signature = signpad.GetImage(Acr.XamForms.SignaturePad.ImageFormatType.Png);
            using (var image = result.GetStream())
                {
                    using (System.IO.Stream stream = await file.OpenAsync(FileAccess.ReadAndWrite))
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            image.CopyTo(ms);

                           byte[] buffer = ms.ToArray();
                            stream.Write(buffer, 0, buffer.Length);
                            fileSize = buffer.Length;
                            await stream.FlushAsync();
                        }
                    }
                }

                await App.Current.MainPage.DisplayAlert("Signature saved");

        }
        catch (Exception ex)
        {
            //Exception comes here
        }


    }

I observed that by instantiating the signature pad control it is impossible to get the stream from it.

And by including the code from the View Model example I found that it would pop up a new control on top of my page

How can I bypass this technique and directly save the signature to a stream from the clicked event of the button on the XAML form when I already have designed the signature pad inside a StackLayout control along with other controls on a Content Page.

Thanks

Rajesh

Are there any Loading / Progress / Waiting Dialogs to be used in the PCL library?

$
0
0

Trying to call a Progress dialog while my app makes an async call to my service. Are here any built in dialogs or know libraries?

Am I doing backgrounding correctly?

$
0
0

Most of my apps I need background threads running - where a method is called at a set interval. This is used mostly for communication with peripheral devices.

When updates are need to passed up to the ui thread I raise events on the ui thread from these background tasks/threads.

In the old days on windows i used to create a new thread and loop at an interval. Now I use a Task, is this a correct way of doing things?
Below is the code I use to have a method called in the background continuously.

The class that uses BackgroundWorkerPoll just assigns a method to PollMethod :

            public class BackgroundWorkerPoll : IBackgroundPoll
                {
                    private readonly Object _threadLock = new Object();
                    private bool _keepGoing = false;
                   private int _sleepMs;
                   private Stopwatch _stopWatch;

                public BackgroundWorkerPoll(int sleepMs)
                {
                    _sleepMs = sleepMs;
                    _stopWatch = new Stopwatch();
                }

                #region IBackgroundPoll Members

                public Func<bool> PollMethod { get; set; }

                public async void StartPolling()
                {
                    if (_keepGoing)
                    {
                        return; // already running
                    }
                    lock (_threadLock)
                    {
                        _keepGoing = true;
                    }

                    await Task.Run(Poll);
                }

                private async Task Poll()
                {
                    while (_keepGoing)
                    {
                        _stopWatch.Restart();
                        PollMethod();
                        _stopWatch.Stop();
                        var diff = _sleepMs - _stopWatch.ElapsedMilliseconds;
                        if (diff > 0)
                        {
                            await Task.Delay((int)diff);
                        }
                    }
                }

                public void StopPolling()
                {
                    lock (_threadLock)
                    {
                        _keepGoing = false;
                    }
                }

                #endregion
            }
        }

Tap Gesture not working properly in IOS

$
0
0

hi,

i am facing problem with tap gesture in IOS.., I have written a code where when u click on a stack it should make entry visible/hide.i had inserted three stacks and entry vertically to make entry visible and hide on stacks tap gesture. its working properly but when u tap the bottom/end stack , it is showing the entry (if it is hidden) but suddenly IOS screen scrolling to top automatically. in android and windows it is working properly but jus in ios the screen scrolls to top on tapping the stack. plz anyone suggest me how to overcome it?

How do you use the Picker control?

$
0
0

Sorry for the general nature of this question, but I would struggle to be more specific, because I have tried so many alternative ways of using the Picker and I just cannot find any way to get it to render on iOS, Android and Windows Phone. I have something that looks passable on iOS, but on Android and Windows Phone, it is a complete mess. Check out the example rendering on iOS and Android in the attached files. You can see that iOS looks absolutely fine, but the same code on Android is a disaster.

Has anyone managed to use this control successfully across more than one platform?

Kind wishes ~ Patrick

Viewing all 58056 articles
Browse latest View live


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