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

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.

Loading a Sqlite db file embedded as a ressource file

$
0
0

Can I, directly from PCL code in a XF app, open up a SQLite file using GetManifestResourceStream ? Or do I need to first copy the file in the user's space in each platform prior to open it (hence using dependency service) ? The SQLite DB is intended to be exclusively read-only!

Thanks

Image animation not working (yet)

$
0
0

Hi,
Short story: I created a custom popup window, when the user finshed the task and tapped the image, it goes down and set the visible false (binding somewhere else) and it goes back, and the another task when finshed the image isVisible set true and appears again, but the image do not come back, and I do not know, why is it not working,
Here is the code:
private async Task HideMessage(object sender, EventArgs e)
{
var imageMessage = sender as Image;
var x =imageMessage.TranslateTo(0, 800, 600, Easing.SinOut);

        var p = Task.Delay(2000);

        await Task.WhenAll(x, p);
        imageMessage.IsVisible = false;
        await imageMessage.TranslateTo(0, 0, 400, Easing.SinOut);




    }

Xamarin Forum - edited post disappeared

$
0
0

Hi Guys,

I spent half an hour yesterday writing a post question on this forum. After saving it I noticed some stupid typo and decided to correct it using "4 hours edit" option. When saved again my post disappeared and I got message it's waiting for approval. How long will the approval take? It's been only 12 hours since that so no biggie yet, but I'm a bit worried it might get lost somewhere in the process (and I really wouldn't like that to happen :smile: )


how to upload image to the server using api in xamarin forms?

Json array parsing as observable collection

$
0
0

Could someone help me with this?
I want to deserialize my json array into an observable collection

Hi! Do you have a great tutorial or lib, how can I share content on Facebook? (without login)

$
0
0

I want to create a share button, and you don't need to login with your facebook account, just tapped and calls facebook app and share the content. Do you have idea for that or tutorial? Thank you for answering!

Binding does not work

$
0
0

Hi Binding Does not work in my code. please tell me guys whats wrong in this code.

Mainpage.cs

    `HttpClient client = new HttpClient();
    var response = await client.GetAsync(string.Format("uri link"));
    string jsonstring = await response.Content.ReadAsStringAsync();
    RootObject item = JsonConvert.DeserializeObject<RootObject>(jsonstring);
    titles.ItemsSource =item.ToString();`

Mainpage.xaml

<ListView x:Name="titles" HasUnevenRows="False" > <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <StackLayout Orientation="Horizontal"> <Label Text="{Binding note}"/> </StackLayout> </ViewCell.View> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

Result.cs

public class Result { public string note { get; set; } } public class Response { public List<Result> results { get; set; } } public class RootObject { public Response response { get; set; } }

Jsonstring format:

` { "response"
{ "results": [
{ "Created By": "non_authenticated_user_live",
"Created Date": "2018-03-05T08:34:04.631Z",
"Modified Date": "2018-03-05T08:34:04.677Z",
"note": "hi",
"_id": "1520238844627x475879674311727300",
"_type": "custom.note"
}
]
}}`

Java.Lang.NullPointerException

$
0
0

An error after during Debug. Is that I missing something?

Java.Lang.NullPointerException:
Attempt to invoke virtual method 'void android.support.v7.widget.ContentFrameLayout.setId(int)' on a null object reference

Viewing all 58056 articles
Browse latest View live


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