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

Bug, iOS, Label with StartAndExpand HorizontalOptions does not expand if multiline (word wrap)

$
0
0

Hello there,

Because a picture is worth a thousand words, let's start with this:
image

As you can see, I am trying to build rows with a left-aligned Label (LayoutOptions.StartAndExpand) and a right-aligned Switch (LayoutOptions.End). I am using an horizontal StackLayout.
This works well in all cases on Android but on iOS the label does not expand any more when the text contains line breaks due to word wrapping.

I have tried many things and played will the LayoutOptions but can't get it to work properly.

I suspect that this is a bug and I will file a report after testing a few more Xamarin Forms versions.

I was wondering if anyone had had the same problem.

I have attached the sample project (zip), using Xamarin.Forms 1.4.4.6392,

Regards,


Approaches/alternatives to embedding chat in xamarin forms applications!

$
0
0

Dear friends,

I'm starting to consider approaches/alternatives to embedding chat in xamarin forms applications, I think that would very useful in at leat two scenarios:

I) Provide a communication channel with application users. In this case, would need just exchange messages between each user and a backend service (to start, we can think this as an another simple user).

II) Provide a social communication between application users. In this case, would desirable to allow direct message (user-to-user) and also create and exchange messages in groups.

Of course, for both the cases would be great supports send files, but initially this is not a required requirement.

In this context, they emerge several questions, such as:

1) The telegram API can be an option to some of above scenarios? Would be possible use telegram API without requires that users have installed telegram app?

2) There are some good framework/service, preferably free, to help us in the above scenarios?

3) What would the drawbacks in an "ad-hoc" implementation? Probably using a cloud no-sql repository, a rest api, push notification or pooling, and etc... What would the important issues to stay tuned?

Well, any ideas or suggestions will be greatly appreciated!

Issue: icon of ToolbarItem not shown in Android

$
0
0

Hi

I do have a problem showing an icon in Android within a ToolbarItem. With iOS there is no problem.

Some background info:

Framework.Xamarin.Forms
- Contains following code:

toolbarItem = new ToolbarItem() { Icon = action.Icon, Text = action.Icon == null ? action.Text : null, Order = ToolbarItemOrder.Primary, Command = action.Command, CommandParameter = action.CommandParameter };

DemoApp.Droid
- Resources
- drawable
- Image.png

In my ContentView I set the icon.

Why is the icon (Image.png -> 20x20 ) not shown in my ToolbarItem?

I hope someone can help me out.

Kind regards

Application windows are expected to have a root view controller at the end of application launch!

$
0
0

Cry.

Suddenly my app I'm working on doesn't work anymore -> I'm now getting the following crash when I start my app:

Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Application windows are expected to have a root view controller at the end of application launch

Now, I've read the Stable release notes which say this

[Upstream change] [iOS] iOS 9 has stricter requirements for setting a RootViewController. "Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Application windows are expected to have a root view controller at the end of application launch". Possible workaround: Set the Window.RootViewController property in the AppDelegate.FinishedLaunching() method. (See the troubleshooting guide for additional details.)

Ok . not good nor do I know why ...

Checking the guide for help .. it says this :

This is error is being raised because app Windows are expected to have a Root View Controller at the end of application launch and your existing app doesn't.
Setup RootViewController property of app Window in FinishedLaunching method in AppDelegate class to point to a View Controller in your app's UI.

Ok .. so I want to try this but I have no idea what View Controller should I use? In fact, I have no idea if i even have any!

I've only got a few classes which inherit from ContentPage. I've not manually made any View Controllers :(

Can anyone help, please? It's very frustrating because I cannot run the simulator anymore to test my app!

Xamarin forms Navigation page

$
0
0

Hi,

is there a way to make navigation page title to the center of the page.

sismail

The type or namespace name 'Xamarin' could not be found

$
0
0

i've Created a xamarin Cross-platform solution (Blank) and it runs normally on android emulator whenever i try to run it on xamarin Live Player i get the below errors

1- AppDelegate.cs(1,1): error: The type or namespace name 'Xamarin' could not be found in the global namespace (are you missing an assembly reference?)
2- AppDelegate.cs(1,1): error: 'AppDelegate.FinishedLaunching(UIApplication, NSDictionary)': no suitable method found to override
3- AppDelegate.cs(1,1): error: The name 'LoadApplication' does not exist in the current context
4- AppDelegate.cs(1,1): error: The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)

i'm running VS 2017 ENT 15.5.6 on Windows 10 Pro. and everything is updated

Height of Stack Layout is always assigning 0

$
0
0

Hi,

I have a Vertical stack layout which i am adding elements to. I want to get the height of the stack layout but it is alway assigning the value of 0.

When I inspect in Visual Studio, the height is definitly showing as non-zero but it doesn't get assigned to my variable.

double chats_Height = view_Chat.Height;

chats_Height is always 0, but view_Chat.Height has a non-zero value.

very strangee as i've never seen this in C# before,

I have the stacklayout inside a scrollview. i want the height of the stacklayout so i can scroll to the end of the scroll view programmatically.

UWP : FillAndExpand expand out of screen of a modal content page

$
0
0

In a modal content page, I have a grid :

<Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="40" /> <RowDefinition Height="40" /> </Grid.RowDefinitions> <StackLayout Spacing="0" VerticalOptions="Start" HorizontalOptions="FillAndExpand" Orientation="Vertical"> <2 LABELS /> </StackLayout> <Button Grid.Row="1" /> <Button x:Name="BadButton" Grid.Row="2" /> </Grid>

The Button called BadButton is pushing out of the screen or is barely visible at the bottom of the screen.
When I checked the size of the MainPage, it says 616px. The Grid size is 640px !

What I am doing wrong ? Is it a bug of Xamarin Forms ?


Azure twitter authentication redirect back to app?

$
0
0

Hi. I am trying to make my twitter authentication redirect back to my app after completing authentication, but it is stuck in twitter's redirect page. what am i doing wrong? Currently trying to implement it on android.

This is what happens:

  1. The app loads
  2. I press Sign-in
  3. I am brought to twitter to sign in
  4. Twitter accepts the sign in and start redirecting me
  5. The app stays with the twitter redirect screen, and never leaves it.

I have added the following to my androidmanifest.xml inside after the tag

                <activity android:name=".MyUriActivity">
                    <activity android:name="com.microsoft.windowsazure.mobileservices.authentication.RedirectUrlActivity">
                      <intent-filter>
                        <action android:name="android.intent.action.VIEW" />
                        <category android:name="android.intent.category.DEFAULT" />
                        <category android:name="android.intent.category.BROWSABLE" />
                        <data android:scheme="THENAMEOFMYAPP" android:host="easyauth.callback"/>
                      </intent-filter>
                    </activity>
                  </activity>

I have added this to the twitter callback URL - EDIT: Had to make the spaces to avoid getting blocked for links on the forums

  https:   //     THENAMEOFMYAPP.azurewebsites.net    /    .auth    /    login/twitter/callback

Added this to my Constants.cs:

    public static string URLScheme = "THENAMEOFMYAPP";
      public static string URLIdentifier = "";

This is my OnCreate in android:

    protected override void OnCreate (Bundle bundle)
    {
        base.OnCreate (bundle);

        // Initialize Xamarin Forms
        Forms.Init(this, bundle);

        // Initialize Azure Mobile Apps
        CurrentPlatform.Init();

        App.Init((IAuthenticate)this);

        // Load the main application
        LoadApplication (new App ());
    }

And this is how i call the authentication:

public async Task<bool> Authenticate()
    {
        var success = false;
        var message = string.Empty;
        try
        {
            user = await TodoItemManager.DefaultManager.CurrentClient.LoginAsync(
               this,
                MobileServiceAuthenticationProvider.Twitter, 
                Constants.URLScheme);

            if (user != null)
            {
                message = string.Format("You are now signed-in as {0}.",
                    user.UserId);
                success = true;
            }
        }
        catch (Exception ex)
        {
            message = ex.Message;
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.SetMessage(message);
        builder.SetTitle("Sign-in result");
        builder.Create().Show();

        return success;
    }

What am i doing wrong, have forgotten or how do i troubleshoot this?

Thanks in advance for your time.

Realtime Xamarin Tesseract detection

$
0
0

I am attempting to use tesseract in Xamarin.Forms for text character recognition on images. On Android, I've implemented the logic using the steps below;

  1. Grab bitmaps of the TextureView.
  2. Convert bitmaps to black and white.
  3. Crop needed from the bitmap image
  4. Set tesseract image with cropped image

Currently facing memory issues and haven't got a way around it so far

Snippets below show the main functions of the code.

    public async void takeContinuousPhotos(){

        byte[] newBytes;
        byte[] bytes;

        while (ocrTextChosen == false){

            bytes = await CapturePhoto();

            newBytes = this.CropPhoto(bytes, new System.Drawing.Rectangle(40, view.Height / 2 - 200, view.Width - 40, 100), (view.Width - 40) * 2, 200);

            if (!_tesseract.Initialized)
            {
                await _tesseract.Init("eng");

                var result = await _tesseract.SetImage(new MemoryStream(newBytes));

                if (result)
                {
                    Device.BeginInvokeOnMainThread(() => {
                        this.ocrText.Text = this._tesseract.Text;
                    }); 
                    _tesseract.Clear();
                    bytes = new byte[0];
                    newBytes = new byte[0];
                }
            }
            else {
                var result = await _tesseract.SetImage(new MemoryStream(newBytes));
                if (result)
                {
                    Device.BeginInvokeOnMainThread(() => {
                        this.ocrText.Text = this._tesseract.Text;
                    });
                    _tesseract.Clear();
                    bytes = new byte[0];
                    newBytes = new byte[0];
                }
            }
        }
    }

    // Capture photo from stream
    public async Task<byte[]> CapturePhoto()
    {
        var ratio = ((decimal)Height) / Width;

        var blackwhiteBitmap = this.toGrayscale(liveView.Bitmap);

        var image = Bitmap.CreateBitmap(blackwhiteBitmap, 0, 0, blackwhiteBitmap.Width, (int)(blackwhiteBitmap.Width * ratio));

        byte[] imageBytes = null;

        using (var imageStream = new System.IO.MemoryStream())
        {
            await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 10, imageStream);
            image.Recycle();
            imageBytes = imageStream.ToArray();
            imageStream.Dispose();
        }

        image = null;
        return imageBytes;
    }

takeContinuousPhotos() is then run on the TextureView delegate method as shown below:

  public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
    {
        camera = Android.Hardware.Camera.Open();
        var parameters = camera.GetParameters();
        var aspect = ((decimal)height) / ((decimal)width);

        var previewSize = parameters.SupportedPreviewSizes
                                    .OrderBy(s => System.Math.Abs(s.Width / (decimal)s.Height - aspect))
                                    .First();

        parameters.SetPreviewSize(previewSize.Width, previewSize.Height);
        parameters.FocusMode = Android.Hardware.Camera.Parameters.FocusModeContinuousPicture;

        camera.SetParameters(parameters);
        camera.SetPreviewTexture(surface);
        StartCamera();

        Task.Run(() => {
            this.takeContinuousPhotos();                
        });
    }

To create an object and send by service

$
0
0

How can i create an object? This object has:

Serial Number,
Description,
Message

All data i get by foreach and i create this object. How can i create and i send by service?

Connect to Oracle using Xamarin Forms PCL

$
0
0

Hi,

I am trying to connect to Oracle from my Xamarin Forms PCL project.

I added the Nuget Oracle.manageddataAccess but getting:

Could not install package 'Oracle.ManagedDataAccess 12.2.1100'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

How can I solve this please?

Thanks,
Jassim

Xamarin Ways to connect to local and external database simultaneously

$
0
0

Hello, I have a question about how I should proceed, I have a xamarim application connected to a sql server database via an external server. It works via internet, the problem and when I do not have a connection I am unable to use, until I have sql lite installed tbm in the app only to save user data, such as login and password. I would like to use this local bank when I did not have a local connection, store it and when the app connects to an internet network synchronize the local data with the external one. Thank you so far.

TableView excess spaces at end of the list

$
0
0

Hi,

I've got a tableview setup with intent as settings. Within this i have added a number of image cells along with a switchcell. however at the end there is a lot of blank space. Is there way to remove this?

Should I just reduce the height of the tableview?

Creating tags which are toggled by user

$
0
0

Fairly new to Xamarin and mobile development so this question has been driving me in endless circles this afternoon. I have a screen where the user sees multiple tags in a horizontal layout like [Tag1] [Tag2] [Tag3]. I want the tags to look like rounded rectangle buttons. The idea is that the user taps which ones they want and those should highlight to a different color. When the user hits submit, I want to loop through each control and determine which ones were chosen.

I haven't been able to understand if I should be using Buttons, Labels, RadioButtons, Switches, Toggles, and whether I need to implement a Custom Renderer or just use the styling in Android / iOS. This has been very confusing and any help is greatly appreciated.


Xamarin Forms fails to create an instance of DI container

$
0
0

I'm using Visual Studio 2017.

Created the default Xamarin Forms project (.net standard 2.0 + android). No changes in project configuration, Debug mode.

Compile -> Build -> Success (simple page with a standard text). Works in simulator, Xamarin Live.

Added Unity/Autofac and created an instance of the container in App. The solution works in simulator, but fails on phone (Xamarin Live, or direct execution).
This error can be reproduced in both Release/Debug modes.

With Unity:

public App ()
    {
        InitializeComponent();

        var c = new UnityContainer(); //this is the only line for Unity example
        MainPage = new App2.MainPage();
    }

Object reference not set to an instance of an object

p.s. tried the approach to skip linking assembly System.Core

With Autofac
Fails on RegisterType with exception:

Target of Add is null (NullReferenceException)

Xamarin Forms Map error on Andriod

$
0
0

I'm getting a Unhandled Exception when debug project.

/////////////////////////////////////////////////////////////////////////////////
Unhandled Exception:

Java.Lang.NumberFormatException: For input string: "@2131493172"
/////////////////////////////////////////////////////////////////////////////////

here the code :
LoadApplication(new App());
at MainActivity.cs

Please help me!

Main.axml error: This project contains resources that were not compiled succesfully, rendering might

$
0
0

I just installed Xamarin (Visual Studio). But I have a problem: When I start a new Android project (Blank app) and I open the Main.axml there is this message: "This project contains resources that were not compiled succesfully, rendering might be affected"

Maybe it's easy to solve, but I can't find what the solution is. Is there anyone who can help me?

Thank you very much.

Does modal page resets navigationstack?

$
0
0

After pushing modal page if I check Navigation.NavigationStack in its OnAppearing method and it is empty list. What is the deal with it? How can I get previous NavigationStack ?

Tabbed Modal Page has no Toolbar and ToolbarItems? Bug?

$
0
0

I came across to a strange behavior today. When I push a tabbed page as navigationpage, code below works. I can see the toolbar items and tool bar.
But If I push same page as modal page without any single code, Below code doesnt work, I dont see any toolbar and toolbaritems.
Toolbar items work on a non-tabbed page so what is the deal with that? it is a bug in xamarin forms?

    <TabbedPage.ToolbarItems>
        <ToolbarItem  />
         <ToolbarItem  />
    </TabbedPage.ToolbarItems>
Viewing all 77050 articles
Browse latest View live


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