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

Xamarin.Forms Video Background

$
0
0

Hi everyone !

I want to use video as the background on the first screen of my application. I searched for it and found a source.

I've completed all the steps. Everything on Android side works very well. To move to the next page, I push the button and move smoothly.

BUT,

The video is played in the background when the app starts on the iOS side. There is no problem. But when I go to the next page by pressing the button, my application gives an error.

How can i solved ?


This APK results in unused code and resources being sent to users?

$
0
0

why google shows below warning for App Bundles? I mean it is clear that google wants us to use app bundles and this is why we see this warning but how does google now my app has unused code and resources? what does it mean exact meaning of "results in unused code and resources"?

Unoptimised APK
Warning:
This APK results in unused code and resources being sent to users. Your app could be smaller if you used the Android App Bundle. By not optimising your app for device configurations, your app is larger to download and install on users' devices than it needs to be. Larger apps see lower installation success rates and take up storage on users' devices.

Best approach to slide between listviews

$
0
0

Im trying to create a view (my image) where you can click on the specific date up top and it will redirect to that dates listview, kinda like a tabbedpage. But the view is itself a part of a tabbedpage (the one in the bottom). How do I best do that?

I disable swiping for the tabbedpage, and want to be able swipe between the dates. Im not sure what approach is the best for this view.

Xamarin.Forms with Navigation TitleView is having left and bottom space in UWP.

$
0
0

Navigation page in UWP is creating space in left and bottom if I use NavigationPage.TitleView to customize the title view.
Can anyone help me in removing space?

Slider ThumImage hides on Maximum value

$
0
0

In UWP, I am using slider control and setting triangle as thumb image. On extreme left or minimum value, image shows correctly. But on dragging it to maximum values it hides out on maximum value.
<Slider.ThumbImageSource> <OnPlatform x:TypeArguments="FileImageSource"> <On Platform="UWP" Value="Assets/Images/Triangle.png"/> </OnPlatform> </Slider.ThumbImageSource>

How to suspend UI / App Shell when manually removin and adding element to App Shell in Xamarin.Forms

$
0
0

My Question:

In Xamarin.Forms 4.2+, can I suspend the App Shell in any way while I am manipulating it? Or can I suspend the whole UI layouting and rending for an instance?

My Situation:

I am creating an App with Xamarin.Forms where I use the new Shell Navigation. Cause I change the Flyout Menu during app runtime, I want to add and remove some of the FlyoutItem by code.

As an example, I have a LoginPage which I want to replace by a UserProfilePage in the App Menu (Flyout Menu). I always have an AppInfoPage in the menu.

Whenever I remove a FlyoutItem, Shell wants to display the next item. So when I remove the LoginPage, Shell displays AppInfoPage or at least calls the constructor and executes the overload of OnAppearing on the AppInfoPage. OnAppearing then does a lot of things to prepare the App info, which is not needed now cause the page will be OnDisappearing just a few ticks later.

Most UI frameworks have some function like this to avoid unneeded UI layouting and rendering. I tried setting IsVisible = false, IsBusy = true and calling BatchBegin(), but none of them helped me.

Collapsing Toolbar Layout in Xamarin Forms

Create and Save Dictionary locally in Xamarin forms

$
0
0

Hi,

I want to store data locally, I know the procedure how to do using a List. Can anyone tell me how to save Data locally in a Dictionary.

Thanks in Advance


Can I have more than one MasterDetailPage in my xamarin forms application?

$
0
0

Can I have more than one MasterDetailPage in my xamarin forms application?

Overriding frame to allow custom radius and shadow

$
0
0

I'm having immense difficulty figuring out an effective way to override Frame to allow for a custom corner radius and shadow. Does anyone have a good solution? It seems this should be functionality within the cross-platform layout, but isn't yet.

Thanks in advance!

Enable Javascript on WebView

$
0
0

Hi,

I am using this to show a LiveStream from uStream (IBM):

var htmlSource = new HtmlWebViewSource();

StringBuilder html = new StringBuilder();

html.AppendLine("<html>");
html.AppendLine("<body>");
html.AppendLine("<iframe src='");
html.AppendLine(streaming_url);
html.AppendLine("' style='border: 0;' webkitallowfullscreen allowfullscreen frameborder='no' width='100%' height='100%'>");
html.AppendLine("</iframe>");
html.AppendLine("</body>");
html.AppendLine("</html>");

htmlSource.Html = html.ToString();

so if you use this URL from IBM:

https://www.ustream.tv/embed/1524

as a test you'll see that you can't interact with the player buttons, e.g. Fullscreen which I guess it's a JavaScript problem

How can i fix this please?

Thanks,
Jassim

Custom View Renderer for Master / Detail but in reverse

$
0
0

In Xamarin Forms we are creating a custom layout similar to the Master / Detail but in reverse. On iOS we were able to write a custom renderer using container views and this works without issue. So on the left is the larger part of the screen and on the right is the smaller part with a navigation page pushing and popping information.

So with iOS this is how it looks and it's accurate with the screen on the left and the navigation on the right:


In Android we're getting the following, where the content page doesn't display the label inside it.

So the Xamarin Form ContainerPage we've created looks like the following:

`
using Xamarin.Forms;

namespace JobConnect.Views.Generic
{
public class ContainerPage : ContentPage
{
public static readonly BindableProperty LeftPageProperty = BindableProperty.Create(nameof(LeftPage),
typeof(ContentPage),
typeof(ContainerPage),
null,
BindingMode.OneWay);

    public ContentPage LeftPage
    {
        get => (ContentPage)GetValue(LeftPageProperty);
        set => SetValue(LeftPageProperty, value);
    }

    public static readonly BindableProperty RightPageProperty = BindableProperty.Create(nameof(RightPage),
        typeof(NavigationPage),
        typeof(ContainerPage),
        null,
        BindingMode.OneWay);

    public NavigationPage RightPage
    {
        get => (NavigationPage)GetValue(RightPageProperty);
        set => SetValue(RightPageProperty, value);
    }

    public ContainerPage(ContentPage leftPage, NavigationPage rightPage)
    {
        LeftPage = leftPage;
        RightPage = rightPage;
    }
}

}
`

The custom Android renderer is currently the following:

`
using Android.Content;
using JobConnect.Droid.Renderers;
using JobConnect.Views.Generic;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using AView = Android.Views.View;

[assembly: ExportRenderer(typeof(ContainerPage), typeof(ContainerPageRenderer))]
namespace JobConnect.Droid.Renderers
{
public class ContainerPageRenderer : PageRenderer
{
AView leftView;
AView rightView;
private IVisualElementRenderer leftPageRenderer;
private IVisualElementRenderer rightPageRenderer;

    public ContainerPageRenderer(Context context) : base(context)
    {
    }

    protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
    {
        base.OnElementChanged(e);

        if (e.OldElement != null || Element == null) {
            return;
        }

        var element = Element as ContainerPage;
        leftPageRenderer = ResolveRenderer(element.LeftPage);
        rightPageRenderer = ResolveRenderer(element.RightPage);

        leftView = leftPageRenderer.View;
        rightView = rightPageRenderer.View;

        AddView(leftView);
        AddView(rightView);
    }

    protected override void OnLayout(bool changed, int l, int t, int r, int b)
    {
        base.OnLayout(changed, l, t, r, b);

        if (changed)
        {
            leftView.Layout(0, 0, r - 640, b);
            rightView.Layout(r - 640, 0, r, b);

            leftView.Invalidate();
            rightView.Invalidate();
        }
    }

    private IVisualElementRenderer ResolveRenderer(VisualElement element)
    {
        var renderer = Platform.GetRenderer(element);
        if (renderer == null)
        {
            renderer = Platform.CreateRendererWithContext(element, Context);
            Platform.SetRenderer(element, renderer);
        }
        return renderer;
    }
}

}
`
Anyone have any pointers on how to make this render correctly in Android, what we could be doing wrong with the renderer?

Can't debug android

$
0
0

Hi, I have a Xamarin.Forms app. I am using Visual Studio 2015.
The debugger in android fail 90% of times. If I hit debug button, it compiles and deploy but the app does not launch in the device.
Is like it is only deploying the solution, because if I launch app manually in device, the last version is installed.

I am not getting any failure log or message.

Rare thing is that sometimes, I don't know how, I am able to debug perfectly the solution.

Someone have this issue before?
Thanks for any help

Advice to handle html files in external storage

$
0
0

Hi guys, i'm a xamarin newbie. I have developed a simple Forms app to display some particular html files (by webview). To store the files i've used embedded resource. Now i need to implement a mechanism to updates of that files...so i've developed an asp net mvc web api. When i call it returns to me a zipfile with updated contents (they must be stored in the sd card). In your opinion, what is the best way to handle a lot of html files stored in the sd storage? Must i copy them to Asset (or assets are write only..?) to visualize them?

Thank you very much for your advices, i'm a little bit confused.

How to clear the Navigation Stack in a Xamarin.Forms 4.0+ Shell app?

$
0
0

I like to remove all pages from the navigation stack and make my current page the new root page. How can I do that?
Whole navigation is done with the new Shell navigation (calling Shell.GoToAsync(route) or the Flyout Menu).
I tried collecting the current stack from Shell.Current.CurrentItem.Navigation.NavigationStack and Shell.Current.Navigation.NavigationStack , but the only element in there is null for any reason.
I am using the latest Xamarin 4.2.848062 version.


Oauth2.0 with Xamarin.Forms iOS/Android

$
0
0

Hi everyone,

I've been trying these days to build a client application using OAuth2.0, but I can say that I succeeded. Firstly, I want to present the context:

  • I have an OAuth2.0 web page. I created an Xamarin.Forms project from where I open that page in browser by calling the following url:
    https://link-to-web-page.com/csc/v0/oauth2/authorize response_type=token&client_id=ClientID&clientSecret=ClientSecret&redirect_uri=http://test-signer/ . I set in the AndroidManifest file an intent filter with the following lines of code:






  • After opening the web page for OAuth2.0, the user must complete username (phone number) and password and he gets an OTP code on the phone and he gets redirected to a page to complete that OTP code. After the user completes OTP code, he gets redirected to the redirect URI set in the calling URL (set in client application with the intent filter -https://test-signer/) and he's now able to select client application to open. Now, in OnCreate method of MainActivity class I can capture the intent that opened the app and get the authorization-code from it. Now I have to call another method which calls the next uri:https://link-to-web-page.com/csc/v0/oauth2/token with a HttpClient().PostAsync(uri, content). The content is a StringContent of JSON type which must contain the next data: "{ \"grant_type\": \"authorization_code\", \"code\": \"" + code + "\", \"client_id\": \""+clientID+"\", \"client_secret\": \""+clientSecret+"\", \"redirect_uri\": \""+redirectUri+"\"}". If that post call is successful, I get the access token and I can do requests to a specified server.

My problem with this approach is that: I open client app, I press the Authorize button, I do the steps on the OAuth2.0 web page and when I get redirected back to client app, I get another instance of the client app (I redirected it to another page of app, not the MainPage which opens when I first start the app).

I tried to do the same thing using nuget Xamarin.Auth following the next link:https://docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/authentication/oauth, but I didn't succeed. I need to implement that solution cross-platform and with intent-filter, now it works just on Android.

Is there anyone who has an ideea of how may I do it? I think it should work with that OAuth2Authenticator but probably I have no idea how to configure it to work. They explain it how to use it for Google, Facebook etc, but not for a particular OAuth2.0 solution.

Thank you very much!

ListView item highlighting doesn't work on iOS

$
0
0

After updating to the newest version of Xamarin.Forms none of ViewCells can be selected no more(on iOS. on Android everything is fine). To make sure, that this error wasn't in my code i've created a new blank solution and tested simple ListView and get same glitch. I only see 1px height blue line when item is selected.

<StackLayout> <Label Text="Welcome to Xamarin.Forms!" HorizontalOptions="Start" VerticalOptions="CenterAndExpand" /> <ListView ItemsSource="{Binding Items}" SelectionMode="Single" SeparatorColor="Red"> <ListView.ItemTemplate> <DataTemplate> <TextCell Text="{Binding .}"/> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout>

Save an image in a specified path from base64 string.

$
0
0

Save an image in a specified path from base64 string.

Public properties and attributes are being nested into Non-public members

$
0
0

Hi, I am working with an App on Xamarin.Forms that instances an object and saves it on a JSON file. I have the following classes

         [Serializable]
            public class CustomTask
            {
                public string collectionId { get; set; }
                public string taskId { get; set; }
                public int taskPosition { get; set; }
                public string taskName { get; set; }
                public int taskHours { get; set; }
                public int taskMinutes { get; set; }
                public int taskSeconds { get; set; }     
            }
         [Serializable]
            public class TaskCollection
            {
                public string collectionId { get; set; }
                public string collectionName { get; set; }
                public int collectionPosition { get; set; }
                public List<CustomTask> tasks { get; set; }

                public TaskCollection() { tasks = new List<CustomTask>(); }
            }

Then I call a method that creates an instance of TaskCollection for testing (which I made rather verbose for testing) :

    public TaskCollection getTC()
            {
                string colId= "Test ID";

                TaskCollection tc = new TaskCollection();
                tc.collectionId = colId;
                tc.collectionName = "Test Task Collection";
                tc.collectionPosition = 1;

                CustomTask ct1 = new CustomTask { collectionId = colId, taskHours = 1, taskId = "1", taskMinutes = 10, taskName = "First Task", taskPosition = 1, taskSeconds = 0 };
                CustomTask ct2 = new CustomTask { collectionId = colId, taskHours = 2, taskId = "2", taskMinutes = 12, taskName = "Second Task", taskPosition = 2, taskSeconds = 0 };
                CustomTask ct3 = new CustomTask { collectionId = colId, taskHours = 3, taskId = "3", taskMinutes = 13, taskName = "Third Task", taskPosition = 3, taskSeconds = 0 };
                CustomTask ct4 = new CustomTask { collectionId = colId, taskHours = 4, taskId = "4", taskMinutes = 14, taskName = "Fourth Task", taskPosition = 4, taskSeconds = 0 };

                List<CustomTask> list = new List<CustomTask>();
                list.Add(ct1);
                list.Add(ct2);
                list.Add(ct3);
                list.Add(ct4);

                tc.tasks = list;

                return tc;
            }

While Debugging I can see that all CustomTask and TaskCollection objects have all their properties under a Non-public members nest, and for each property an additional object called <"propety name">k_BackingField was created. For List list, the inspection shows a value of (null) right after being instantiated, yet it won't trigger a null reference during the Add calls. When it goes on to serialization and storage all it creates is an empty string, since everything became non-public.

I have tried using non automatic setters and getters, marking the class with [Newtonsoft.Json.JsonObject], and marking [DataContract] with [DataMember] on each property, changing the Linking options from None to SDK Assemblies Only to SDK and User. Also tried cleaning, rebuilding, restarting, and deleting obj and bin folders. Also tried creating new classes on new files, and changing targets Android API 23, 24, 25, and 26). None of these have worked.

My Xamarin version is 2.5.1.4449 and the project is a Xamarin.Forms Shared Project. I appreciate any new direction you might give me into making this simple data structure to be recognized properly. Thank you.

Update

Made a new Xamarin.Forms Project with .Net Standard, and ended up with the same results.

Also, I'm using Visual Studio 2017 (Version 15.6.6)

Android Emulator not consuming API and giving error System.Net.WebException: 'Failed to connect to

$
0
0

l have an api backend in a .net core web app and have written the code to consume the api in xamarin.forms. when l run the code
l get the following error.

System.Net.WebException: 'Failed to connect to /127.0.0.1:44360'.

Below is my code in xamarin.forms

public MainPage()
{
InitializeComponent();
Comic();
}

    public async void Comic()
    {
        using(var httpClient = new HttpClient()){
            var response = await httpClient.GetStringAsync("https://127.0.0.1:44360/api/comic");
            var comic = JsonConvert.DeserializeObject<List<Comic>>(response);
            comicList.ItemsSource = comic;
        }
    }

A bit of research says something about configuring the web app to use 127.0.0.1 instead of localhost and it been
specific to android.what can l do to fix this error.

Viewing all 81910 articles
Browse latest View live


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