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

App breaks after navigating to many pages.Can anyone help?

$
0
0

I have set largeheap true in manifest file and in android properties set heap to 1G

Still application breaks


Google playstore in app purchase unsuccessful. Paid 60php for it.

$
0
0
Hello guys, I need your help; I actually paid 60php for nothing at google play in app purchase. The app I paid was a game called Nexomon. I bought the full version of the game because I can't continue the story with the lite version. Instead of having the game's full version, I didn't get it instead. It says payment unsuccessful. But my balance was subtracted 60php.. I paid the app for nothing. Help please, Anyone?. It's my first time buying online

Xamarin.Forms.UTemplates

Xamarin.Forms.Templates extension for Visual Studio 2017

$
0
0

Xamarin.Forms.Templates extension for Visual Studio 2017:

https://marketplace.visualstudio.com/items?itemName=mohamedalinouira.XamarinFormsTemplates

*Provides a collection of templates for Xamarin.Forms projects.
*Uses several NuGet packages (Navigation, Controls, Behaviors, Extensions, Converters) that allow you to quickly create Xamarin.Forms applications using MVVM Design Pattern :

Xamarin.Forms.Navigation : https://www.nuget.org/packages/Xamarin.Forms.Navigation/
Xamarin.Forms.ToolKit.Controls : https://www.nuget.org/packages/Xamarin.Forms.ToolKit.Controls/
Xamarin.Forms.ToolKit.Behaviors : https://www.nuget.org/packages/Xamarin.Forms.ToolKit.Behaviors/
Xamarin.Forms.ToolKit.Converters : https://www.nuget.org/packages/Xamarin.Forms.ToolKit.Converters/
Xamarin.Forms.ToolKit.Extensions : https://www.nuget.org/packages/Xamarin.Forms.ToolKit.Extensions/

Thank you for having taken your time to provide us your valuable feedback !

Mohamed Ali NOUIRA
www.github.com/medalinouira

OxyPlot initialize renderer error

$
0
0

I need to do some basic plotting in my App with the help of the OxyPlot NuGetPackage extension. I have followed the online tutorials on how to set it up and as far as i can tell i did it correctly. I put the Init call to initiate the renderer right after the Xamarin.Forms.Forms.Init in every of the 3 Folders(Android, IOS, UWP) like so(Android as example):
base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); OxyPlot.Xamarin.Forms.Platform.Android.PlotViewRenderer.Init(); LoadApplication(new App());

Now everytime i start the app i get an exception along the lines of:"Visualization error. Dont forget to initialize renderer in Android MainActivity.cs" which I clearly did. I'm getting really frustrated at this as i cant find any fix on the Interwebs and other plotting libraries seem way too cumbersome to use. I would appreciate any help i can get!
Thanks beforehand

Deleting the Media file from storage

$
0
0

Hi,
I have been using the Media Plugin to capture the photo from android device using XF. I have noticed that the files are stored in specified directory. My question is that how can I delete these files from the storage after usage how can I do that.

I tried to delete the file after showing but the files are still in "samples" directory.

         var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions()
                                {
                                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,
                                    CompressionQuality = 92,
                                    AllowCropping = true,
                                    SaveToAlbum = true,                        
                                    Directory = "Samples",
                                    Name = (Guid.NewGuid().ToString("N") + ".jpg")  
                               });


                                if (photo != null)
                                {
                                    imgPhoto.Source = ImageSource.FromStream(() => { return photo.GetStream(); });
                                                          if (File.Exists(photo.Path))
                                                {
                                                    File.Delete(photo.Path);

                                                }
                                     photo.Dispose();



                                }`

the File.Delete(photo.Path) statement executes without error however the actual file still remains in the storage.
If its not possible at this level is there a way to delete all files in specific directory on launch or close of the application? How can I access the Folder path?

Thanks in advance

while calling rest api get url getting Newtonsoft.Json.JsonSerializationException

$
0
0

i am getting this error
"Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'servicecall.Items4+RootObject' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.\nTo fix this error either change the JSON to a JSON object (e.g. {\"name\":\"value\"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\nPath '', line 1, position 1.\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract) [0x00058] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00012] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0007f] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <5424c375059648559663368cade11c20>:0 \n at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <5424c375059648559663368cade11c20>:0 \n at servicecall.fourthlisturl+d__8.MoveNext () [0x000ce] in D:\MySaiworkSpace\servicecall\servicecall\servicecall\fourthlisturl.xaml.cs:46 "

How to implement the chat bot application using DirectLine Api of MicroSoft ??

$
0
0

I need to implement the chat bot using directline api


Graphics, SkiaSharp

$
0
0

Hi all,

I am currently looking at the SkiaSharp Example here: https://developer.xamarin.com/guides/cross-platform/drawing/introduction/#Obtaining_an_SKCanvas.

It seem's easy enough and i implemented my code as the following:

    public TestController()
    {
        InitializeComponent();
        DrawXamagon();
    }

    protected void DrawXamagon() { 
        using (var surface = SKSurface.Create(width: 640, height: 480, colorType:SKColorType.Rgb565, alphaType: SKAlphaType.Premul))
        {
            SKCanvas canvas = surface.Canvas;

            // clear the canvas / fill with white
            canvas.Clear(SKColors.White);

            // set up drawing tools
            using (var paint = new SKPaint())
            {
                paint.IsAntialias = true;
                paint.Color = new SKColor(0x2c, 0x3e, 0x50);
                paint.StrokeCap = SKStrokeCap.Round;

                // create the Xamagon path
                using (var path = new SKPath())
                {
                    path.MoveTo(71.4311121f, 56f);
                    path.CubicTo(68.6763107f, 56.0058575f, 65.9796704f, 57.5737917f, 64.5928855f, 59.965729f);
                    path.LineTo(43.0238921f, 97.5342563f);
                    path.CubicTo(41.6587026f, 99.9325978f, 41.6587026f, 103.067402f, 43.0238921f, 105.465744f);
                    path.LineTo(64.5928855f, 143.034271f);
                    path.CubicTo(65.9798162f, 145.426228f, 68.6763107f, 146.994582f, 71.4311121f, 147f);
                    path.LineTo(114.568946f, 147f);
                    path.CubicTo(117.323748f, 146.994143f, 120.020241f, 145.426228f, 121.407172f, 143.034271f);
                    path.LineTo(142.976161f, 105.465744f);
                    path.CubicTo(144.34135f, 103.067402f, 144.341209f, 99.9325978f, 142.976161f, 97.5342563f);
                    path.LineTo(121.407172f, 59.965729f);
                    path.CubicTo(120.020241f, 57.5737917f, 117.323748f, 56.0054182f, 114.568946f, 56f);
                    path.LineTo(71.4311121f, 4056f);
                    path.Close();

                    // draw the Xamagon path
                    canvas.DrawPath(path, paint);
                }
            }
        }

I have no errors and the code steps through fine, but noting is displayed (It should display the Xamarin logo). There dosen't seem to be much more to the example, am i supposed to initialise a canvas or Skview in the XAML, or is there any mistakes anybody can see in my example?

Thank you in advanced.

Update UI from async Action

$
0
0

Hi,

I'm currently uisng a command to allow the user to choose some files.
PickFilesCommand = new Command(PickFiles);

When I want to update my UI it dosen't work. The begin Device.BeginInvokeOnMainThread is executed at the end of my method. The problem is that I need my method to be async because of UWP.

` private async void PickFiles()
{
// Récupération des fichiers choisis par l'utilisateur
List selectedFiles = await DependencyService.Get().SelectFilesAsync();

        if(selectedFiles.Count > 0)
        {
            Device.BeginInvokeOnMainThread(()=> { IsLoading = true; });
            //Work with files ... (sychronous)
    Device.BeginInvokeOnMainThread(()=> { IsLoading = false; });
        } 
}`

What I want is to update my UI at the start of my method and at the end.
How can I do it ?

Thanks

Image ScrollView with HorizontalFill

$
0
0

Hello Everyone!

I'm trying to make a scrollView with a couples of image in it but it's not showing how I want it.

Basicaly, I need each image to stretch to max width and keep aspect ratio. Ex : screen width is 1000px, img is 10x40, I need it to stretch to 1000x4000

I have tried many things but it does not seems to work.

Here is part of my code :

            <Grid Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="#2D2D2D" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

                <ScrollView VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">

                    <StackLayout  x:Name="imgScroll" VerticalOptions="FillAndExpand">

                        <Image Source="conso_jeune_drogue.jpg" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Margin="10" />

                        <Image Source="conso_pas_fort.jpg" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Margin="10" />

                        <Image Source="conso_jeune_drogue.jpg"  HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Margin="10" />

                        <Image Source="conso_pas_fort.jpg"  HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Margin="10" />

                    </StackLayout>
                </ScrollView>
            </Grid>

so this is the structure, a stack in a scroll in a grid

I have tried setting minimumwidth and minimumHeight but the result is the same.

So I tried adding images in the code as such :

foreach (string s in imgToLoad)
            {
                var newImg = new Image();
                newImg.Source = s;

                var ratio = newImg.Height / newImg.Width;
                newImg.MinimumWidthRequest = Application.Current.MainPage.Width - 20;//width - margin
                newImg.Margin = 10;
                newImg.HorizontalOptions = LayoutOptions.FillAndExpand;
                newImg.VerticalOptions = LayoutOptions.FillAndExpand;
                imgScroll.Children.Add(newImg);
            }

where imgScroll is my scrollView and imgToLoad are my images's names.

And that is where it start to get weird. with this, it work in my android emulator ( nexus 6, api 7.0) but it does not on my phone using xamarin live ( galaxy s8, API 8.0)

Unfortunately I cant post images because I haven't been on this forum for long enough :/

so its on imgur and the link is
imgur.com/QtRRcS5 for the one that is not working
imgur.com/WJdkpFA for the one that is working

Any idea? is it supposed to work but somehow xamarin live is having problem?

If you need any clarifications do not hesitate,

Thanks a lot!

FlatButton renderer for android

$
0
0

Hello,

I use this renderer in my Droid project for get flat button but after an OS reinstall and an update packages VS it's doesn't work whereas before this renderer has working, any ideas?

using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using Android.Content;


[assembly: ExportRenderer(typeof(Button), typeof(MyProject.Droid.Renderers.FlatButtonRenderer))]
namespace MyProject.Droid.Renderers
{
    public class FlatButtonRenderer : ButtonRenderer
    {
        // Constructors
        public FlatButtonRenderer(Context context) : base(context) { }

        // Methods
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);
        }
    }
}

Best regards

XLabs NullReference with Xamarin Forms on Android

$
0
0

I have a problem using XLabs in combination with Xamarin.Forms under Android. I have a very simple sample project with two XAML Pages and ViewModels.

I ALWAYS get a NullReference exception after compiling with no errors in the LaunchApplication(new App()); method. (see StackTrace below).
UpdateActionBarBackgroundColor();

Perhaps XLabs in NOT compatible with the new Android 5.x or 6.x Material Design ? Because the XLabs base class XFormsApplicationDroid does not have the TabLayoutResource and ToolbarResource properties, so I have to comment them out ?

Here the absolut standard initialization code in the

public class MainActivity : XFormsApplicationDroid
{
    protected override void OnCreate (Bundle bundle)
    {
        //TabLayoutResource = Resource.Layout.Tabbar;
        //ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate (bundle);

               var resolverContainer = new SimpleContainer();
               resolverContainer.Register<IDevice>(t => AndroidDevice.CurrentDevice);

              Resolver.SetResolver(resolverContainer.GetResolver());

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

          LoadApplication (new App ());
    }
}

StackTrace:

at Xamarin.Forms.Platform.Android.Platform.UpdateActionBarBackgroundColor () [0x00010] in :0
at Xamarin.Forms.Platform.Android.Platform.set_CurrentNavigationPage (Xamarin.Forms.NavigationPage value) [0x000f1] in :0
at Xamarin.Forms.Platform.Android.Platform.UpdateActionBar () [0x00063] in :0
at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x000bd] in :0
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page page) [0x000b7] in :0
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage () [0x0000c] in :0
at Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication (Xamarin.Forms.Application application) [0x0002d] in :0
at MVVMBase.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0004a] in /Users/marcoseraphin/Projects/MVVMBase/Droid/MainActivity.cs:35

I tried different version combinations:

XLabs: 2.0.5783
Xamarin.Forms: 2.0.1.6495

I also tested the current 2.2.0.45 Xamarin Forms and also different pre versions. But always the NullReference error at runtime.
Even the XLabs pre versions does not have the ToolbarResource property.

On GitHub are different opinions concerning some errors if it belongs to XLabs or Xamarin Forms.

Any ideas ?

Thanx

Marco

Unable to set ICommand properties in my view model

$
0
0

I am developing a simple Xamarin.Forms app using a MVVM approach with VS 2017. Everything works as expected in UWP but my Android project does not execute the lines of code that get/set ICommand properties at all. I can set a breakpoint on the line that sets the property value, as well as the line before and the line after. I break on both lines before and after, but not on the line that sets the property.

Here is my view model code:

public LoginPageViewModel(INavigation navigation) : base() 
{
        Navigation = navigation;
        LoginButtonClicked = new Command(Login, () => true);
        PasswordHintButtonClicked = new Command(PasswordHint, () => true);
}

And my XAML.cs:

btnLogin.SetBinding(Button.CommandProperty,  nameof(vm.LoginButtonClicked), BindingMode.OneWay);
btnPasswordHint.SetBinding(Button.CommandProperty, nameof(vm.PasswordHintButtonClicked), BindingMode.OneWay);

As I said, I can break on setting the Navigation property but not the command properties. If I move Navigation = navigation to the last line of the constructor I still break on it.

I've also tried:

private ICommand _loginButtonClicked; public ICommand LoginButtonClicked { get { return _loginButtonClicked ?? (_loginButtonClicked = new Command(Login, () => true)); } }

This should be pretty straightforward. Maybe I made a mistake configuring the Android emulator? I've been beating my head against this for a few days now, if anyone has seen something like this before I'd appreciate a nudge in the right direction.

Thanks!

How can I implement localization in Xamarin.Forms Shared project in VS2017

$
0
0

I downloaded the samples provided by Xamarin docs and followed the tutorial but couldn't apply it to my VS17 shared project.
I can only add .resw resource files from VS17 to my Shared Project. I Also tried adding existing .resx files. Both formats are not recognized in my Shared Project where I need to set the culture and use them in my .xaml files.
Any idea on how to get localization working? Please share some code or sample in VS17 Xamarin.Forms Shared project.


Navigating from One Tab to another taking time - I am using custom control for Tab

$
0
0

I am creating App in Xamarin Form which has three Tabs and each tab has a content page

Page 1 - It has a chart control and a List view which is created using grid control.
Page 2 - It has just a List view which is created using the grid control
Page 3 - It also has just a List view which is created using the grid control

For tabs I am using button control in the Custom page which we will call as HeaderFooter page and this HeaderFooter page is inherited in each content page[ Page 1,Page 2,Page 3].

When we tab the Page 1 button an event gets fired in the HeaderFooter page,there I am creating the object for Page1 like

Page1 obj1 = new Page1();

In the Page 1 constructor I will get the data from SQLite DB frame the chart object and List view object.

Then I am passing the Page 1 object to Navigation

Navigation.PushAsync(obj1) ;

So the same process has been followed for all three tabs.

So the issue here is for navigating from one tab to other it is taking minimum 2.5 seconds.

For navigating to Page 1 it is taking 7.5 seconds as it has the charting control and List view control. [ data can be 1000 records]
For navigating to Page 2 it is taking 2.8 seconds as it has List view control [ data can be 100 records]
For navigating to page 3 it is taking 2.5 seconds as it has list view control and very less data [ data for now 4 records]

I would like to know why it is taking this much time and how can I improve the performance.

Note : I could not use the xamarin Tabs control because of the UI design.

Can I embed a NavigationPage into a place holder?

$
0
0

This is currently my main page which is a tabbed page like instagram.

public partial class MainPage : ContentPage
{

    void Home(object sender, System.EventArgs e)
    {
        var page = new Feed();
        PlaceHolder.Content = page.Content;
    }
    void Schedule(object sender, System.EventArgs e)
    {
        var page = new Schedule();
        PlaceHolder.Content = page.Content;
    }
    void Messages(object sender, System.EventArgs e)
    {
        var page = new Messages();
        PlaceHolder.Content = page.Content;
    }
    void Departments(object sender, System.EventArgs e)
    {
        var page = new Departments();
        PlaceHolder.Content = page.Content;
    }
    void More(object sender, System.EventArgs e)
    {
        var page = new Options();
        PlaceHolder.Content = page.Content;

}

Each button displays the content of the newly instantiated class.

My problem is that I am unable to Navigate within the newly instantiated class.
I initially believe that I would need to put a wrap the placeholder content within a NavigationPage in order to use navigation functions

Here is my departments class which shows up if I click on the departments tab...

namespace ProvigramAlpha
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Departments : ContentPage
{

// HERE IS WHERE I ATTEMPT TO NAVIGATE TO A NEW PAGE.
private async void DepartmentSelected(object sender, SelectedItemChangedEventArgs e)
{
var dpt = e.SelectedItem as Department;
await Navigation.PushAsync(new DepartmentDetailPage(dpt));
}

    public Departments()
    {
        InitializeComponent();
        dptsListView.ItemsSource = new List<Department>
        {


            new Department { Text = "Branch Sales & Operations"},
            new Department { Text = "Call Center"},
            new Department { Text = "Call Services"},
            new Department { Text = "Call Center"},
            new Department { Text = "Card Services"},
            new Department { Text = "Consumer Lending"},
            new Department { Text = "Information Technology"},
            new Department { Text = "Investment & Insurance"},
            new Department { Text = "Marketing"},
            new Department { Text = "Project Management Office"},
            new Department { Text = "Risk Management"},
            new Department { Text = "Service Quality & Training"}
        };



    }
}

}

Is there any way I can make this work without using a "Tabbed Page"? All suggestions are appreciated! Thank you!

Frame not rounding corners in UWP

$
0
0

I have an app that I am working on and have hit somewhat of a roadblock when it comes to designing the UI. The frames xaml does not seem to automatically cut of the corners of the child views on windows phones like it does on android and ios. I've attached pictures of this happening. I've run a couple of tests and I know that the frame in windows is indeed being drawn as well as the border that I expect to see. I set the IsClippedToBounds to true and I even ran tests by setting the frame's corner radius to 50 in xaml. Is there a way to get this working?


Detect and Open another App on device

$
0
0

Can someone tell me the best approach to accomplishing this for IOS and Android. Code samples or links to related discussions would be most appreciated.

thanks

Xamarin.Forms Label won't word wrap inside a Grid

$
0
0

I define a Grid like this:

var easyGrid = new Grid();
easyGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
easyGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

I then populate the Grid with text and bullets (emulating a bulleted list) like so:

for (int i = 0; i < bullets.Length; i++) {
    easyGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });

    var label = new Label { Text = "•" };
    label.SetValue(Grid.RowProperty, i);
    easyGrid.Children.Add(label);

    var text = new Label { Text = bullets[i] };
    text.SetValue(Grid.RowProperty, i);
    text.SetValue(Grid.ColumnProperty, 1);
    easyGrid.Children.Add(text);
}

But on iOS the Label controls don't word wrap as they do outside a Grid layout control. Is this a bug with Xamarin.Forms on iOS? Otherwise how do I get them to word-wrap?

Viewing all 89864 articles
Browse latest View live


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