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

How to load records at the bottom of ListView/RepeatableStack dynamically when scrolls down?

$
0
0

I am working on Xamarin mobile app development. I am using RepeatableStack to display collection records on a CarouselPage. This is working fine, when i have less number of records.

But when i have huge number of records, the page gets stuck on load and takes few seconds. This gives bad user experience.

I would like load more records on the fly, when the user scrolls the list down to the bottom. I would like to load it, only when user scrolls down to the bottom. So that, the RepeatableStack will have less number of records when the page loads. Has any one resolved this scenario in Xamarin(C#)?


Xamarin.forms: Unable to connect to locally hosted web service.

$
0
0

Hi guys,
I've been trying to connect with web service deployed in my local (which is running in tomcat). And I'm deploying my project in Android device. As you can see in the code below that I've used my local PC's IP address. Also in Android Manifest file, I turned on the "INTERNET" permission. If I run this url directly in browser, I get expected result. Please note that I had to remove "http" from the code in order to post it here.

` public async Task<List> getHospitalsByCityAsync(string city)
{
List hospitals = null;

        string RestUrl = "192.168.15.100:8080/unsaarAPI/bismillah/city/" + city;
        var uri = new Uri(RestUrl);

        try
        {
            var response = await client.GetAsync(uri);
            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();
                NswHospitalSearch nswHs = JsonConvert.DeserializeObject<NswHospitalSearch>(content);
                hospitals = nswHs.hospitals;
            }
        }
        catch (HttpRequestException e)
        {
            Debug.WriteLine(e.InnerException.Message);
        }
        catch (Exception ex)
        {
            Debug.WriteLine(@"              ERROR {0}", ex.Message);
        }
        return hospitals;
    }`

During debug, its doesn't reach at line if (response.IsSuccessStatusCode) and after a while I get
Error: ConnectFailure (Connection timed out)

I've no clue how to fix this. I've been surfing online many hours; but can't find a suitable solution.
Can any one help. I would really appreciate it.

Thanks.

Expandable ListView

$
0
0

i am new in xamarin forms and i need to make expendable list view by Populating data from web services
Thank you

How to create Background Service in xamarin forms ??

$
0
0

How to create background service in xamarin forms !! I create a task to meet my friend today at 10 am and close the app, remind before 10 minutes to the meeting time phone is ringing or vibrate.

XF vs PWA

$
0
0
Hi all! What's your thoughts about XF vs PWA? Will MS continue to Invest alot in XF, now that PWA might be a better way to fill the app-gap?

Threading problem: how to await?

$
0
0

We have a SDK shipped in two native libraries, let's say lib.framework for iOS and lib.aar for Android.
We needed to create a version for Xamarin, so we created a binding library for each of them (lib_ios_binding.dll and lib_android_binding.dll).
On top of this we created another abstraction level to enable the use of our SDK from Xamarin.Forms projects, a PCL made up of lib.dll, lib.ios.dll and lib.android.dll. This level provides a set of interfaces (lib.dll) which are implemented in both native libraries (lib.ios.dll and lib.android.dll) and the instances are resolved at runtime by the Dependency Service.

Our approach for consuming the server API in the native libraries is implemented by delegates/listeners. The delegate/listener of each operation is passed through the invoker method and called back once the response is received. We handle threads natively, by sending the operation to a background threads and returning immediately. Once the operation is completed (it could take a while) we call back the listener/delegate on the main (UI) thread.

Now we are requested to use the async / await approach by an integrator but we are not able to make it work properly.
As for now we have tried to use the TaskCompletionSource in the PCL level, but we are losing context as we are not being called back all the times. The delegate/listener is not being invoked properly. We can assure the requests are being launched and they are reaching the server.
So we need a way to create something like a task to run the native request and be able to wait until the response is received and return the result.

Is this possible to achieve? What are we misunderstanding or doing wrong?
Any help would be highly appreciated.

xamarin forms youtube api full integration

$
0
0

Is there any possibility to have full integration with youtube using XF?
for example,

  • I want to implement "like", "subscribe" and "comment" options using the api (not inside youtube app), directly integrating into my app. So user can comment, like subscribe over my own interface. then I forward request to via api to update my channel.

How can I access the external memory of my device?

$
0
0

I am developing an App in which I have to access the external memory of the device to create a PDF.
I tried using Dependency Services but it is not working because this returns an emulated memory.

This is the sentence I use to get the directory (from the Android project): Android.OS.Environment.ExternalStorageDirectory.Path but the result it returns is "/storage/emulated/0 "

Obviously rooting the device is not an option since my clients will use the App from devices that are not rooted.
Has anyone else had this problem before?


How to make a desktop app with xamarin 3.0?

$
0
0

In a video about xamarin form 3:

it seems, according the video, there's possibility to create a cross-platform desktop app (so I understand),
I also found the nuget package Xamarin.Forms/3.0.0.296286-pre2, but examples
found is only for VS mac, not for pc. I've not found any template to start coding xamaring forms 3.0 desktop app in vs2017, so I'm stuck, where can I start?

DynamicResource doesn't load into global resources using MergedDictionaries but does into local?

$
0
0

Hi all,

While refactoring our global resources from the application XAML into separate resource dictionaries, I recently discovered that our one dynamic style does not appear to properly load when using the MergedDictionaries-tag to re-insert the now separate resource dictionaries into the application XAML as global resources. That is, UI-controls that formerly had their Style-attribute set to {DynamicResource MyDynamicStyle} now no longer pick up on changed to values within "MyDynamicStyle", while styles defined (page) locally and inheriting from the dynamic style using the BaseResourceKey-attribute do observe the changes.

Has anybody else experienced this? Is this expected behaviour? Personally, I strongly suspect this is a bug...

History

Once upon a time our App had a very big monolithic UI-assembly in which all pages, renderers, UI-controls and XAML-extensions lived happily along-side each other. Then, one day, the solution's main developer decided that in order for others to more easily work together on the solution, it would be a good idea to separate the code into various smaller assemblies. This led to problems with XAML-IntelliSense in some UI-assemblies, as the application XAML was placed in the topmost-level assembly and lower-lying assemblies could therefore not access the styling at design time. No problems were experienced at runtime, however.

What's been done

In order to enable the IntelliSense and hopefully resolve some issues one of our developers is experiencing with certain styles not being found at random moments, I've decided to split the application's resource dictionary up into separate dictionaries that can each be included in the assembly they are most closely associated with. This way higher-level assemblies should, in one way or another, have access to the styles from lower-level assemblies (at least in concept).

The result is the following partitioning (from lowest-level to highest-level assembly:
1. Style-assembly "Constants"-dictionary: contains constants used in XAML; "TextStyles"-dictionary: contains both implicit and explicit (i.e. named) text styles.
2. Xaml-assembly "Converters"-dictionary: defines the IValueConverters available to the App.
3. Controls-assembly "MyControlStyle"-dictionary: styling for the MyControl UI-control and contains the dynamic style.
4. Pages-assembly application dictionary: combines all other dictionaries using MergedDictionaries.

Each of the dictionaries is initializing properly using a code-behind that calls InitializeComponent from the constructor.

Dictionaries are merged as follows:

<?xml version="1.0" encoding="utf-8" ?>
<Application
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:styling="clr-namespace:Styling.Xaml;assembly=Styling"
    xmlns:converters="clr-namespace:Xaml.Converters;assembly=Xaml"
    xmlns:controls="clr-namespace:Controls.Styling;assembly=Controls>

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <styling:Constants />
                <converters:Converters />
                <styling:TextStyles />
                <controls:MyControlStyle />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

The "MyControlStyle"-dictionary and dynamic style have the following set-up:

  • A background colour is defined for the control, "MyControlColor";
  • An implicit style is defined for the control that sets things like a font, text size, and a hard-coded default colour;
  • A dynamic style is defined as "MyDynamicStyle", which uses "MyControlColor" through a DynamicResource-binding in the Color-property's Setter--tag.

"MyControlColor" is set in the App's Application class at some point following application start, using this.Resources["MyControlColor"] = aColor;

What's observed

From the above I'd expect to just be able to continue using "MyDynamicStyle" as before. However, this is not the case. Any MyControl that previously would get styled using the dynamic style is now no longer being styled. Except for a single instance, where "MyDynamicStyle" is used as a BaseResourceKey to define a (page) local resource, as here changes to "MyControlColor" are being picked up.

Interestingly, if you duplicate "MyDynamicStyle" into the application resource dictionary, including the same key, everything seems to continue working fine thanks to the fallback mechanism used to resolve resources. This is no solution, though, as the above scenario is but step one in the total desired refactoring...

So why is this happening? Why are styles being treated differently when immediately included in the application resource dictionary versus when the same is done through merged dictionaries? Is this what's expected to happen?

Thanks in advance for the help! If this turns out to be a bug, I'll of course file an official bug report.

All the best,
Alexander.

ListView Json and save Switch IsToggled

$
0
0

I would like to save the data of this switch from a list of json and save the change of the switch for the following contentPage



<ListView.ItemTemplate>


<ViewCell.View>




</ViewCell.View>


</ListView.ItemTemplate>

public async void LlenarListaEstado()
{
try
{
ListEstado manager = new ListEstado();

            var res = await manager.getEstados();

            if (res != null)
            {
                ListaIncidencias.ItemsSource = res;
            }
        }
        catch (Exception ex)
        {
            await DisplayAlert("Error", ex.Message, "Aceptar");
            return;
        }
    }

Does MinimumHeightRequest work at all?

$
0
0

If I set a MinimumHeightRequest on a Label within a StackLayout or Grid, it is ignored on both iOS and Android. Is this a bug?

Compress Web service Data

$
0
0

Hi guys i am currently calling my WCF web service with the following and its working just fine

        string strAddress = App.EndPointAddress;
        BasicHttpBinding httpBinding = new BasicHttpBinding();

        EndpointAddress address = new EndpointAddress(strAddress);
        ChannelFactory<ITCService> channel = new ChannelFactory<ITCService>(httpBinding, address);

        var svc = channel.CreateChannel(address);

However my setup data is currently in excess of 50mb in size and i would really like to turn on gzip compression to speed things up a little.

What are my options to do so?

i would really like to keep the web service calls in my PCL project to avoid platform specific code

I am willing to make the service Restful if this has a clear path to compression.

Any help would be greatly appreciated

Collapsing Nav Bar / Toolbar on Scroll

$
0
0

Summary

The ability to set a property on a ScrollView or ListView that allows the Navigation Bar / Toolbar to collapse on scroll up and appear on scroll down. This would require the page to be hosted inside a NavigationPage.

API Changes

Page
public View ScrollView { get; set; }

This would then listen to the scroll events to handle the collapse. On Android I would suggest using the CoordinatorLayout and CollapsingToolbarLayout.

Intended Use Case

Common UI practice to scroll the navigation bar away on scrolling down on a List / ScrollView to increase vertical real estate

Deserialize Json and bind in ListView

$
0
0

Hi Guys
I am new with Xamarin Forms
and i want to deserialize this json and put the data in listview
that is my json and i download this json from the last.fm
and this is my class that i create with newtonsoft (special thanks from Creater :smile: )

 public class Items
    {
        public string TrackName { get; set; }
        public string ArtisterName { get; set; }
    }


    public class Rootobject
    {
        public Tracks tracks { get; set; }
    }


    public class Attr
    {
        public string page { get; set; }
        public string perPage { get; set; }
        public string totalPages { get; set; }
        public string total { get; set; }
    }



    public class Streamable
    {
        public string text { get; set; }
        public string fulltrack { get; set; }
    }



    public class Image
    {
        public string text { get; set; }
        public string size { get; set; }
    }

    public class Artist
    {
        public string name { get; set; }
        public string mbid { get; set; }
        public string url { get; set; }
    }
 public class Track
    {
        public string name { get; set; }
        public string duration { get; set; }
        public string playcount { get; set; }
        public string listeners { get; set; }
        public string mbid { get; set; }
        public string url { get; set; }
        public Streamable streamable { get; set; }
        public Artist artist { get; set; }
        public Image[] image { get; set; }
    }
public class Tracks
    {
        public Track[] track { get; set; }
        public Attr attr { get; set; }
    }

Can anyone help me to deserialize this json and bind listview with xaml


button in listview clickable?

$
0
0

Can anyone help me i have listview with imagein viewcells so how to enable the click event only for image.

Thanks in advance.

Prism: Back button on Android closes app when popup is open

$
0
0

Hello everyone,

I was working with popups in Prism. With the following code:

_navigationService.NavigateAsync(nameof(TestPopup));

The popup is added to the navigation stack. Therefore, I expect it go to the previous page when pressing the Android hardware back button. Too bad, it doesn't, it just closes the app (because there is nothing more in the navigation stack?)

Here is a test project where I reproduced it in:
https://github.com/GyllionElderen/PrismPopupTest

Does anyone know what to do to make the app go back to the root page instead of closing the app?

UWP - error APPX1101: Payload contains two or more files

$
0
0

I've been banging my head against the wall on this one - it happens on a freshly cloned repo

Its a Forms PCL project with UWP. I am using a ACR.Settings which requires me to install the nuget on the UWP project and the Forms project. I have no idea the cause. Here is the full error, an ideas?

E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(1748,5): error APPX1101: Payload contains two or more files with the same destination path 'Acr.Settings.pdb'. Source files: [E:\wp\SmartFill\SMC-1-setup-uwp-jenkins-build\SmartCart.UWP\SmartCart.UWP.csproj] E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(1748,5): error APPX1101: C:\Users\jenkins\.nuget\packages\acr.settings\7.0.2\lib\uap10.0\Acr.Settings.pdb [E:\wp\SmartFill\SMC-1-setup-uwp-jenkins-build\SmartCart.UWP\SmartCart.UWP.csproj] E:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\AppxPackage\Microsoft.AppXPackage.Targets(1748,5): error APPX1101: E:\wp\SmartFill\SMC-1-setup-uwp-jenkins-build\SmartCart.Forms\bin\Debug\Acr.Settings.pdb [E:\wp\SmartFill\SMC-1-setup-uwp-jenkins-build\SmartCart.UWP\SmartCart.UWP.csproj]

Activate Tab using Prism

$
0
0

I am using Prism with my Xamarin Forms application. I have a home page with two tabs- A and B. Tab A has a button which when pressed should activate Tab B. How can I do that with Prism? Both the tabs have separate view models and each view model implements IActiveAware. I am currently using Event Aggregator but that seems really unnecessary to me for just activate tab?

Thanks

Apurva

Xamarin Media Plugin doesn't works on Android

$
0
0

Hi,
I've installed the plugin "Xam.Plugin.Media".
The plugin works fine on IOS but on Andorid the app crash as soon it starts.

I have followed the readme.txt that come after the installation of the plugin, so my files are:

MainActivity.cs:

using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Plugin.Permissions;
using Plugin.Permissions.Abstractions;
using FFImageLoading.Forms.Droid;

namespace SgatMobileV2.Droid {
    [Activity(Label = "SgatMobileV2", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity {
        protected override void OnCreate(Bundle bundle) {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            CachedImageRenderer.Init(enableFastRenderer: true); // Inizializza il plugin FFImageLoading

            LoadApplication(new App());
        }

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, global::Android.Content.PM.Permission[] grantResults) {
            PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }
}

Resources/xml/file_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
  <external-files-path name="my_images" path="Pictures" />
  <external-files-path name="my_movies" path="Movies" />
</paths>

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="it.volos.SgatMobile" android:installLocation="auto">
  <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.CAMERA" />
  <application android:label="SgatMobileV2.Android" android:icon="@drawable/icon">
    <provider android:name="android.support.v4.content.FileProvider" android:authorities="it.volos.SgatMobile.fileprovider" android:exported="false" android:grantUriPermissions="true">
      <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data>
    </provider>
  </application>
</manifest>

But after the app starts, this error is triggered:

System.NullReferenceException: Object reference not set to an instance of an object.

Can anyone help me please?

Thank you!

Viewing all 58056 articles
Browse latest View live


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