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

Does anyone have a sample implementation of expandable listview on shared project in xamarin forms

$
0
0

Im new in Xamarin app development and iv tried looking for a way to implement an sample of a button with an onlick event that displays a list view with child underneath it?


UIKeyboard height in Xamarin IOS is not right in the first time.

$
0
0

I am listening the event using this

notification = UIKeyboard.Notifications.ObserveWillShow(KeyboardWillShow);

 void KeyboardWillShow(object sender, UIKit.UIKeyboardEventArgs args)
        {
          var gg=  args.FrameEnd.Size.Height;
            KeyboardShowing?.Invoke(this, new KeyboardHeightEventArgs(args.FrameEnd.Height));
        }




 var keyboard = DependencyService.Get<IKeyboardNotifications>();
                keyboard.StartListening();
                keyboard.KeyboardShowing += (s, e) =>
                {
                    var arg = e as KeyboardHeightEventArgs;
                    Device.BeginInvokeOnMainThread(() => {                 
                    //    SendMessageGrid.TranslationY = arg.Height == 0 ? 0 : -arg.Height - SendMessageGrid.Height;
                    });
                };

When the event occurs the first time then the event gives height slightly higher and then after the first occurrence, it gives the right height.
For example, here it gives me 258 at first and in second it gives 216.

await UserDialogs.Instance.PromptAsync doesn't await/prompt after resuming from locked screen

$
0
0

Hello,

I'm using Acr.UserDialogs 6.3.8 and am trying to figure out why after minimizing the xamarin forms app on droid and locking the screen that when I come back in the dialog doesn't await. When I first start up the app the dialog awaits accordingly. I put a break on var prompt and when I hit F10 it never goes to the next line or prompts.

I have to use Acr.UserDialogs 6.3.8 because I have a dependency on xamarin.android.support 25.3.1

public async Task PerformEpicLogin(bool tryAltMethod = false)
{
.....
var pc = new PromptConfig
{
MaxLength = 4,
InputType = InputType.NumericPassword,
Title = "Enter your Passcode",
OkText = "Login",
};

                var prompt = await UserDialogs.Instance.PromptAsync(pc);
                if (prompt.Ok)
                {
                    ShieldText = "logging in...";
                    epicService.DoLoginWithPasscode(prompt.Text);
                }
                else
                {
                    ShieldText = "";
                }

         .....
         return true;
    }

Thanks for any insights you may have.

How bad is this code?

$
0
0

Hello again:

This is not realted with previous questions at all, and want to know how bad is what I'm going to propose.
I wanted to pass a value to the previous page, but I though that to pass the entire ViewModel from one page to another just for this was too much.
The idea is to pass to the parent page filter the ID of a item created on the child page. That way, the parent list will shows only the recently created item, so, from the child ViewModel I added this to the CreateItem command:

                    if ((Navigation != null) && (Navigation.NavigationStack.Count >= 2))
                    {
                        Page tempPage = Navigation.NavigationStack[Navigation.NavigationStack.Count - 2];
                        ((ParentViewModel)tempPage.BindingContext).SearchBarTextToFind = newItem.ToString();
                    }
                    await Navigation.PopAsync();

I think this is bad coding, but I'm just getting a page, and only modifying his ViewModel (a binded variable to the form), and it works, but should I change it?

Thanks.

"D/AbsListView( 3323): viewType is heaer or footer" message constantly scolloing in debug

$
0
0

Anyone know why the message below is constantly filling up the debug window? it seems the message has "header" spelled incorrectly as well. What does it mean?

02-08 23:28:45.031 D/AbsListView( 3323): viewType is heaer or footer
02-08 23:28:45.041 D/AbsListView( 3323): viewType is heaer or footer
02-08 23:28:45.051 D/AbsListView( 3323): viewType is heaer or footer
02-08 23:28:45.231 D/AbsListView( 3323): viewType is heaer or footer
02-08 23:28:45.241 D/AbsListView( 3323): viewType is heaer or footer
02-08 23:28:45.241 D/AbsListView( 3323): viewType is heaer or footer

Nathan

How to Go About Requesting Data from a User?

$
0
0

Hello, everyone.

I have a Xamarin Forms app and a Windows Forms app. I'm looking for a way to request a specific user to send their GPS data to a database. Right now I've got database connectivity through a WCF service. What I want to do is have someone click a button on the Windows Forms app to send a request to the Xamarin Forms app where it will get the user's lat/long and return it to the database. I'm using the Geolocator plugin to get GPS data.

I'm relatively new to Xamarin Forms so if someone could just point me in the right direction, I'd appreciate it.

Slider circular bar

$
0
0

Hi,
How to achieve Slider circular bar
in xamarin forms.

Binding to xamarin.forms ListView

$
0
0

Using xamarin.forms .Net Library to dev an app with MusixMatch api. I've created the necessary class and the Http request works, but it's not passing the response class properties to my ListView in xaml. Any help will be appreciated. Thanks. Below is my code.

TrackListResponse.cs
public class TrackListResponse
{
public Message message { get; set; }

        public class Header
        {
            public int status_code { get; set; }
            public double execute_time { get; set; }
            public int available { get; set; }
        }

        public class PrimaryGenres
        {
            public List<object> music_genre_list { get; set; }
        }
    public class SecondaryGenres
    {
        public List<object> music_genre_list { get; set; }
    }

    public class Track
    {
        public int track_id { get; set; }
        public string track_mbid { get; set; }
        public string track_isrc { get; set; }
        public string track_spotify_id { get; set; }
        public string track_soundcloud_id { get; set; }
        public string track_xboxmusic_id { get; set; }
        public string track_name { get; set; }
        public List<object> track_name_translation_list { get; set; }
        public int track_rating { get; set; }
        public int track_length { get; set; }
        public int commontrack_id { get; set; }
        public int instrumental { get; set; }
        public int @explicit { get; set; }
        public int has_lyrics { get; set; }
        public int has_lyrics_crowd { get; set; }
        public int has_subtitles { get; set; }
        public int has_richsync { get; set; }
        public int num_favourite { get; set; }
        public int lyrics_id { get; set; }
        public int subtitle_id { get; set; }
        public int album_id { get; set; }
        public string album_name { get; set; }
        public int artist_id { get; set; }
        public string artist_mbid { get; set; }
        public string artist_name { get; set; }
        public string album_coverart_100x100 { get; set; }
        public string album_coverart_350x350 { get; set; }
        public string album_coverart_500x500 { get; set; }
        public string album_coverart_800x800 { get; set; }
        public string track_share_url { get; set; }
        public string track_edit_url { get; set; }
        public string commontrack_vanity_id { get; set; }
        public int restricted { get; set; }
        public DateTime first_release_date { get; set; }
        public DateTime updated_time { get; set; }
        public PrimaryGenres primary_genres { get; set; }
        public SecondaryGenres secondary_genres { get; set; }
    }

    public class TrackList
    {
        public Track track { get; set; }
    }

    public class Body
    {
        public IList<TrackList> track_list { get; set; }
    }

    public class Message
    {
        public Header header { get; set; }
        public Body body { get; set; }
    }
}

Http Request which is being passed to xaml ListView(TrackList)
public async void SearchBtn(object sender, EventArgs e)
{
string search = SearchField.Text;
try
{
var content = "";
HttpClient client = new HttpClient();

                var RestUrl = "http://api.musixmatch.com/ws/1.1/track.search?q_track=" + search + "&page_size=3&page=1&s_track_rating=desc";
                client.BaseAddress = new Uri(RestUrl);

                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.GetAsync(RestUrl);
                content = await response.Content.ReadAsStringAsync();

                var items = JsonConvert.DeserializeObject<TrackListResponse>(content);

                TrackList.ItemsSource = items.message.body.track_list;

            }
            catch (Exception ex)
            {
                string exception = ex.Message;
            }
        }

Xaml

<ListView.ItemTemplate>


                                <StackLayout Orientation="Horizontal"  HorizontalOptions="FillAndExpand">
                                    <StackLayout Orientation="Vertical"  HorizontalOptions="FillAndExpand">
                                        <Label Text="Artist Name:" TextColor="Black"/>
                                    <Label Text="Song Title:" TextColor="Black"/>

                                    </StackLayout>
                                    <StackLayout Orientation="Vertical"  HorizontalOptions="EndAndExpand">
                                    <Label Text="{Binding artist_name}" TextColor="Black"/>
                                    <Label Text="{Binding track_name}" TextColor="Black"/>

                                    </StackLayout>
                                </StackLayout>

                        </StackLayout>

                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

Xamarin Blank Screen

$
0
0

I am trying to explore Xamarin, trying to create simple CURD project.

I was able to make some progress by watching youtube video's, but I am not sure what went wrong all of the sudden I am getting blank screen in my emulator when I am trying to deploy the project.

Firstly it showed me error stating

'the targetFrameWorkVersion is greater than my project version. You
need to increase the version for the project'.

I tried it, I increased my project version. This issue got resolved but gave birth new error.

Secondly

'To deploy this application, your deployment target should be running
Windows Universal Runtime version 10.0.16299.0 or higher. You
currently are running version 10.0.14393.2007. Please update your OS,
or change your deployment target to a device with the appropriate
version.'

I looked up for newer version of OS, but it seems my OS is already up to date.

I really appreciate if anyone help me out with tips or clue.

Environment is as follows

  • Visual Studio: 2017
  • Operating System: Windows 10

Cannot find Toolbar

$
0
0

Hello everybody!

In MainActivity i trying to get a Android.Support.V7.Widget.Toolbar, but he does not find. After the line of code below
ToolBar = FindViewById(Resource.Id.toolbar); ToolBar is null.
MainActivity

using Acr.UserDialogs;
using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Support.V7.Widget;
using Android.Views;
using MDOSchedule.Droid.Extensions;
using Xamarin.Forms;


namespace MDOSchedule.Droid.Activities
{
    [Activity(Label = "MDOSchedule", 
              Icon = "@drawable/icon", 
              Theme = "@style/MainTheme",
              MainLauncher = true,
              ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        public static Toolbar ToolBar { get; private set; }

        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;
            ToolBar = FindViewById<Toolbar>(Resource.Id.toolbar);

            base.OnCreate(bundle);

            UserDialogs.Init(() => (Activity)Forms.Context);

            Forms.Init(this, bundle);            

            RegisterServices();

            LoadApplication(new App());
        }


        #region Private Methods

        private void RegisterServices()
        {
            DependencyService.Register<OpenAppAndroid>();
        }

        #endregion
    }
}

ToolBar Resource

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

Custom Control for iOS - Hour and minute selector.

$
0
0

Hello,
I am working on an app that requires the user to select the time for how long something took. Specifically the hours and minutes. I saw that in iOS the UIDatePicker has a mode called "countDownTimer". However creating a custom renderer for time picker and setting the mode property will cause a argument exception when the user sets the minutes. It thinks the Time property is incorrect.

Is there a simple way to do this or not really? I believe it would be possible to create a custom entry where the InputView is set to a UIDatePicker but i am unsure how to ensure values make it correctly between the picker, binding, and entry field (while converters are still being applied).

Here is some of the code I have tried.

[assembly: ExportRenderer(typeof(HourMinutePicker), typeof(HourMinutePickerRenderer))]
namespace XamarinFormsPlayground.iOS
{
    public class HourMinutePickerRenderer : TimePickerRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<TimePicker> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                var picker = Control.InputView as UIDatePicker;

                if (picker != null)
                {
                    picker.Mode = UIDatePickerMode.CountDownTimer;

                }
            }
        }
    }
}

Thanks,
Timko

Visual Studio Emulator for Android asking for HAXM instead of Hyper-V?

$
0
0

I am learning cross platform mobile app development for the first time and a few days ago had been struggling to get Visual Studio 2017 to deploy properly to ADV emulator. It was way too slow, unresponsive, and stall Visual Studio into a busy/wait state that require abrupt termination of the devenv.exe process even after closing the emulator.

That was the short summarised story; the long story with all the details and errors was submitted in another post (24 Oct) which for some reason got stuck in some moderation vacuum and hasn't appeared in this forum again.

ADD NOTE: It seems editing posts for typing mistakes sends them to some hidden place. So I've had to re-post this question.

Anyway, I understood a large contributor to the slow performance is the lack of Intel HAXM to accelerate the emulated device. Since I have Hyper-V running (on this Surface Pro 4) and that appears to be mutually incompatible with HAXM. Also I believe even with HAXM available it would only boost Intel Atom x86 virtual devices? ARM-based devices would still run punctured, and my target device was ARM.

But eventually I got around to learn that Visual Studio has its own emulator for Android separate from the default Android SDK emulator, which utilises Hyper-V. I looked at the installer options and sure enough it was there, so I checked it in. On re-launching VS2017 I saw that it added four more new target VisualStudio-based Android devices for my Xamarin.Android project. I tested a deploy to one of those devices and then a similar warning popped up

VisualStudio_android-23_x86_phone will run unaccelerated

This emulator does not have hardware acceleration enabled, and its performance will be impacted. We recommend to either:

  • Enable hardware acceleration on this machine by installing Intel© HAXM and disabling Hyper-V (requires a system restart).

I am confused what's happening here; isn't the Visual Studio Emulator for Android supposed to use Hyper-V?

Also when I check out the new Tools > Visual Studio Emulator for Android... option I can only see device profiles up to API level 23. No option for level 24/25?

What difference between ZXing.Net.Mobile.Forms and ZXing.Net.Mobile for QR code?

$
0
0

QR code scan function is needed to add into my Xamarin.Forms app. ZXing.Net.Mobile seems the most popular component. But ZXing.Net.Mobile.Forms is also available. What's the differences between ZXing.Net.Mobile.Forms and ZXing.Net.Mobile? Which one is more easy to be used? Thanks for your help

The referenced component Xamarin.iOS could not be found

$
0
0

hello

just opened some older project on a new installed visual studio 2017.
Now im getting this error:

The referenced component 'Xamarin.iOS' could not be found

In the folder C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework im missing all 'Xamarin. ...' folders.
On my old pc it works with vs 2017.

Is there a way to install the framework manually?

Simple PopupMenu Plugin for UWP/WinRT/Android/iOS

$
0
0

Hey all,
As a few of you sent me emails regarding this, I added some basic documentation for my popupmenu plugin.

Essentially, you pass it a view and an itemssource, and it will display a flyover next to the view. Its not very verbose and feature rich, but its not supposed to be! For anyone who wants a lot more, 100% check out rotorgames implemention: Rg.Plugins.Popup.

Feel free to give it a play, its pretty simple to implement and allows you a tad more flexibility over the forms actionsheets!

https://github.com/SKLn-Rad/Xam.Plugin.PopupMenu

~ Ry


Why in Xam.Forms UWP, OnAppearing and OnDisappearing are called when navigating to a content page?

$
0
0

Hey guys,

So I have an existing Xamarin.Forms app (android and iOS), and I'm recently starting to work on the UWP (which was included when I created the project, is just that I never worked on it), and for some reason the buttons on my MainPage weren't triggering my Clicked events.

Turns out that when I navigate to the MainPage, I noticed that the OnAppearing() method (where I declare all my event handlers) is invoked as expected, but then OnDisappearing() method is called immediately after, de-registering the event handlers from my controls.

Has this happened to someone else out there? Thanks.

Is there a way to disable the predictive keyboard toolbar for a Forms Entry field?

$
0
0

There appears to be a way to do this directly in iOS by manipulating the UITextAutocorrectionType field. But can it be done in a platform-agnostic way in the Forms Entry field?

Dynamically change status bar text color on Xamarin Forms iOS

$
0
0

Hi guys!

I'm having some trouble changing the status bar text color dynamically in my app. I know that there is an info.plist property to modify it for the whole application but I wanted to change it dynamically. For instance click a button and change from dark to light.

Is it possible?

can't get notification in android when app is in sleep mode

$
0
0

hello,i am trying to add onesignal pushnotification sdk in my app ,but when i am try to test app then i get notification in ios perfectly but in android when app is going to sleep mode at first time it does not get notification but when it reresume it works perfectly.
it does in all version of android.

Is there any solution of very slow Xamarin.Forms start on Android phone?

$
0
0

Hello, I developed a Xamarin.Forms app and I test it in a physical phone, a Motorola with Android 7, octacore and 4GB RAM. The main screen of my app opens in 4s and there only have three buttons, and a few labels. I don't do processing when the app is started, only I read value of App properties. After Google search, I read that there is a known problem of Xamarin.Forms. Is there any solution?

Thanks!

Viewing all 58056 articles
Browse latest View live