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

How do I put a title bar on the top of my Androis/iOS app that remains visible at all times

$
0
0

Hi,
I want to put a title bar at the top of my app that remains visible regardless of which page the user has navigated to.

I have looked at the multi-pages, carousel, tabbed, master detail etc. but I have not found any examples of apps which place a title bar at the top of the app (containing menu and search) (see. image below).

What I really need is a hamburger menu or titlebar with hamburger menu and search button above a TabbedPage.
Is this possible?


Grid of buttons loads too long

$
0
0

Hello there,

I'm trying to programm Minesweeper and after I created the grid i wanted to check out how the grid looks but it took like 30 seconds to load. So I just wanted to ask if there is a better way to create a grid of buttons or some way to fix the problem. Here is the code that creates the grid:

public partial class MainPage : ContentPage
{
    int difficulty;
    int lenght= 8, height = 8, mines = 10;

    public MainPage()
    {
        InitializeComponent();
    }

    private void Difficulty(int difficulty)
    {
        if (difficulty == 0)
        {
            lenght = 8;
            height = 8;
            mines = 10;
        }   else if (difficulty == 1)
        {
            lenght = 16;
            height = 16;
            mines = 40;
        } else if (difficulty == 2)
        {
            lenght = 16;
            height = 30;
            mines = 99;
        }
    }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            var fieldButton = new Style(typeof(Button))
            {
                Setters = {
                new Setter { Property = Button.BackgroundColorProperty, Value = Color.FromHex ("#585858") },
                new Setter { Property = Button.CornerRadiusProperty, Value = 0 },
                new Setter { Property = Button.FontSizeProperty, Value = 40 }
            }
            };


            var controlGrid = new Grid { RowSpacing = 1, ColumnSpacing = 1 };
            controlGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(150) });
            for (int i = 0; i < lenght; i++)
            {
                controlGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
            }

            for (int i = 0; i < height; i++)
            {
                controlGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
            }

            var button = new Button
            {
                Image = "friendly_face.png",
                BackgroundColor = Color.Transparent,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center,
            };

            button.Pressed += FacePressed;
            button.Clicked += FaceClicked;
            button.Released += FaceReleased;

            Grid.SetColumnSpan(button, lenght);
            controlGrid.Children.Add(button);

            for (int x = 0; x < lenght; x++)
            {
                for (int y = 1; y <= height; y++)
                {
                    for (int i = 0; i <= lenght * height; i++)
                    {
                        controlGrid.Children.Add(new Button { ClassId = i.ToString(), Style = fieldButton }, x, y);
                    }
                }
            }

            Content = controlGrid;
        }
    //Animation for the face button
    private void FacePressed(Object sender, EventArgs e)
    {
        (sender as Button).Image = "friendly_face_pressed.png";
    }

    private void FaceClicked(Object sender, EventArgs e)
    {
        (sender as Button).Image = "friendly_face.png";            
    }

    private void FaceReleased(Object sender, EventArgs e)
    {
        (sender as Button).Image = "friendly_face.png";
    }
}

How can I change a BoxView color on mouse hover?

$
0
0

How can I change a BoxView color on mouse hover?

Is there a way to add a trigger for "IsMouseOver" on a grid with a label?

$
0
0

I have a grid with several rows. I want the color to change to a custom color when mouse is over. Is there a way to do this?

How do I change the text lineheight?

$
0
0

Hi guys,

I'm trying to change the lineheight of a label but I couldn't figure it out. Can somebody help me out?

How to find the cause of: Xamarin.Forms targets have been imported multiple times

$
0
0

I'm working my way thru the book "Creating Mobile Apps with Xamarin Forms" and a lot of the sample code requires some work to get it running, which is all very educational and helps me learn and remember. However I can't find the cause of this one;
Chapter 20, MandelbrotProgress, gives me an error in the Xamarin.Formsbook.Toolkit project:

Xamarin.Forms targets have been imported multiple times. Please check your project file and remove the duplicate import(s).

Can somebody point me at the root cause of this please. I cannot find any obvious duplicates in the project file, but there are some error conditions defined in there which I am suspicious of.

Also, is there a specific forum or support area for the above mentioned book?

How to use Firebase in Xamarin.Forms?

$
0
0

How to use Firebase in Xamarin.Forms? As I'm not able to find anything how to use in Forms.

Custom Map Renderer isn't working on Android Platform in Xamarin forms app

$
0
0

i Dont get OnMapReady method to override after inheriting from MapRenderer Class , MapRenderer doesn't Contain the method OnMapReady to OverLoad.. What could be the problem ?
they have OnMapReady Method in their MapRenderer Class but when i inherit a MapRenderer Class than there is No OnMapReady to Overload, and if i use IOnMapReadyCallBack to write the OnMapReady Method, then also i am unable to get the map in my Xamarin.forms app when running on Android Platform.
Here is My code for CustomRenderer for Maps in Android Platform to draw a Polygon on a map, but i haven't even got the map on the screen

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Gms.Maps.Model;
using Xamarin.Forms.Maps;

using Android.Gms.Maps;
using Xamarin.Forms;
using MapsTrial;
using MapsTrial.Droid;
using Xamarin.Forms.Maps.Android;

[assembly: ExportRenderer(typeof(CustomMap), typeof(CustomRenderer))]
namespace MapsTrial.Droid
{
    public class CustomRenderer :MapRenderer,IOnMapReadyCallback
    {
        List<Position> shapeCoordinates;
        GoogleMap map;

        public CustomRenderer(Context context) 

        {
        }



   public void OnMapReady(GoogleMap googleMap)
        {

            map = googleMap;


            var polygonOptions = new PolygonOptions();
            polygonOptions.InvokeFillColor(0x66FF0000);
            polygonOptions.InvokeStrokeColor(0x660000FF);
            polygonOptions.InvokeStrokeWidth(30.0f);

            foreach (var position in shapeCoordinates)
            {
                polygonOptions.Add(new LatLng(position.Latitude, position.Longitude));
            }
            NativeMap.AddPolygon(polygonOptions);
        }


        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Map> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                // Unsubscribe
            }

            if (e.NewElement != null)
            {
                var formsMap = (CustomMap)e.NewElement;
                shapeCoordinates = formsMap.ShapeCoordinates;
                Control.GetMapAsync(this);
            }
        }




    }
}

XAML Example of adding a visual element based on a condition

$
0
0

As the title says, I am interested in adding a visual element inside the XAML file, depending on the value of a property, or anything else outside the XAML.
I don't want to hide it (change the visibilty), but not creating it instead. I read Conditional XAML, but honestly I didn't get how it can be done.
IsEnabled property doesn't seem to be what I'm searching for as well.
So, is this even possible? If so, can you please provide a simple example of it?

Share Invite via WhatsApp, Facebook and other.

$
0
0

I want share app invite txt via WhatsApp, Facebook and other.
guys you have any idea please share with me.!

Google vision not read codebar only in huawei

$
0
0

Hi,

I need some help,

in my app i use Visio api and works fine in almost all the diveces but i am having this trace

05-22 17:15:39.903 W/DynamiteModule( 2125): Local module descriptor class for com.google.android.gms.vision.dynamite not found.
05-22 17:15:39.912 I/DynamiteModule( 2125): Considering local module com.google.android.gms.vision.dynamite:0 and remote module com.google.android.gms.vision.dynamite:1702
05-22 17:15:39.912 I/DynamiteModule( 2125): Selected remote version of com.google.android.gms.vision.dynamite, version >= 1702

i have this to read barcodes

 [Activity(Label = "Scanner", Theme = "@style/MainTheme")]
    public class Vision_scanner : AppCompatActivity, ISurfaceHolderCallback, IProcessor,Scanner_Vision
    {
        SurfaceView surfaceView;
        TextView txtResult;
        BarcodeDetector barcodeDetector;
        CameraSource cameraSource;
        const int RequestCameraPermisionID = 1001;
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
        {
            switch (requestCode)
            {
                case RequestCameraPermisionID:
                    {
                        if (grantResults[0] == Permission.Granted)
                        {
                            if (ActivityCompat.CheckSelfPermission(ApplicationContext, Manifest.Permission.Camera) != Android.Content.PM.Permission.Granted)
                            {
                                //Request Permision  
                                ActivityCompat.RequestPermissions(this, new string[]
                                {
                                   Manifest.Permission.Camera
                                }, RequestCameraPermisionID);
                                return;
                            }
                            try
                            {
                                cameraSource.Start(surfaceView.Holder);
                            }
                            catch (InvalidOperationException)
                            {
                            }
                        }
                    }
                    break;
            }
        }

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

            try
            {
                SetContentView(Resource.Layout.Scanner);
                surfaceView = FindViewById<SurfaceView>(Resource.Id.cameraView);
                txtResult = FindViewById<TextView>(Resource.Id.txtResult);

                barcodeDetector = new BarcodeDetector.Builder(this)
                    .Build();

                cameraSource = new CameraSource
                    .Builder(this, barcodeDetector)
                    .SetRequestedPreviewSize(640, 480)
                    .SetAutoFocusEnabled(true)
                    .Build();

                surfaceView.Holder.AddCallback(this);
                barcodeDetector.SetProcessor(this);

            }
            catch (Exception EX)
            {
                EX.ToString();
            }
        }

        public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
        {
        }

        public void SurfaceCreated(ISurfaceHolder holder)
        {
            if (ActivityCompat.CheckSelfPermission(ApplicationContext, Manifest.Permission.Camera) != Android.Content.PM.Permission.Granted)
            {
                //Request Permision  
                ActivityCompat.RequestPermissions(this, new string[]
                {
                    Manifest.Permission.Camera
                }, RequestCameraPermisionID);
                return;
            }
            try
            {
                cameraSource.Start(surfaceView.Holder);
            }
            catch (InvalidOperationException)
            {
            }
        }

        public void SurfaceDestroyed(ISurfaceHolder holder)
        {
            cameraSource.Stop();
        }

        public void ReceiveDetections(Detections detections)
        {
            SparseArray qrcodes = detections.DetectedItems;
            if (qrcodes.Size() != 0)
            {
                txtResult.Post(() =>
                {                    
                    App.variablesGlovales.CodigoBarras = ((Barcode)qrcodes.ValueAt(0)).RawValue;

                    if (App.variablesGlovales.campoCodigo == "Placa")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "Placa", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }
                    else if(App.variablesGlovales.campoCodigo == "Serie")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "Serie", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }
                    else if (App.variablesGlovales.campoCodigo == "PlacaAF")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "PlacaAF", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }
                    else if (App.variablesGlovales.campoCodigo == "SerieAF")
                    {
                        MessagingCenter.Send<Xamarin.Forms.Application, string>(App.Current, "SerieAF", ((Barcode)qrcodes.ValueAt(0)).RawValue);
                    }           

                    Finish();                    
                });
            }
        }

only in huawei devices

please help

thanks

How to add a json layer in xamarin forms google map ??

$
0
0

I want to add a json layer into my ios map, i am using xamarin.forms.google map to create map.I s thre any solution to add Json layer into my map.I got the solution in android , but I am struggling with ios

Please help me

This is my android code for adding json layer

      layer = new GeoJsonLayer(gmap,new JSONObject( App.Shared.App._result.ToString()));
        layer.AddLayerToMap();

App.Shared.App._result : it contains the geoJson values

Xaml Previewer - Sqlite error

$
0
0

Hi,

I am running VS 2017 and when I try to open the Xaml previewer I get a red exclamation on the previewer with the error : "SQLite.SQLite Exception"

Has anyone else had this problem?

I must say XAML previewer is one of the worst tools I have worked with. It's like it was written the night before the release of VS 2017.

Thanks
Kevin

Remove Status Bar

$
0
0

Hi guys. I don't want the status bar in my app but I don't undertand why.
Is there a simple way to REMOVE the status bar in Xamarin Forms?

problem in retrieve data from google calendar - android

$
0
0

Hello,
I have a problem on retrieve data from google calendar.
If I use google calendar v3 api, I receive exception on retrieve CalendarList or EventsList:

    [0:] Error Google.Apis.Requests.RequestError
    Login Required [401]
    Errors [
        Message[Login Required] Location[Authorization - header] Reason[required] Domain[global]
    ]

My code

            var service = new CalendarService(new BaseClientService.Initializer()
            {
                ApiKey = "...", 
                ApplicationName = "..."
            } );

            CalendarListResource.ListRequest req = service.CalendarList.List();
             var calendarList = req.Execute();
           .......

API key currently does not have application restrictions

another variant I tried

    var eventsUri = Android.Provider.CalendarContract.Events.ContentUri;

            string[] eventsProjection = {
                    Android.Provider.CalendarContract.Events.InterfaceConsts.Id,
                    Android.Provider.CalendarContract.Events.InterfaceConsts.Title,
                    Android.Provider.CalendarContract.Events.InterfaceConsts.Dtstart,
                    Android.Provider.CalendarContract.Events.InterfaceConsts.Dtend
            };

            var loader = new CursorLoader(Android.App.Application.Context, eventsUri, eventsProjection,
                               null, null, "dtstart DESC");
            Android.Database.ICursor cursor = null;
            try
            {
                var obj_loaded = loader.LoadInBackground();
                cursor = obj_loaded as Android.Database.ICursor;
            }

Here the situation is strange - it works OK in the debug version, but in the release version I receive cursor is null

What wrong in the first and second variant?


How to implement voice to text

$
0
0

I am working on a cross platform project and I would like to add simple speech to text into an entry element for user to comment by voice instead of typing.
I do not know specifically yet which library to add or how to implement it. I have found Microsoft cognitive Bing speech but still not sure about using it.
can someone please guide me which way is the best to implement voice to text in Xamarin Forms?

Chat Application based on Xamarin forms Source code

$
0
0

Hi All

I notice many questions about developing a chat application in Xamarin forms .

So i decide to release a source code for you guys and for all beginners to develop there self more and to use some ready code if they like

WoWonder Messenger v1.3

Source code >> https://github.com/Doughouzlight/Xamarin_Forms_Wowonder-Messenger-v1.3

The application is based on Xamarin forms which is related to the Wowonder Social script

The solution includes more than 20+ features, The new versions after this version has been switched and developed on Xamarin android

Reading Logo in Qrcode

$
0
0

Hi Guys,

I am currently using Zxing.Net.Mobile to read a barcode scanning. How can I get a logo from barcode.

Please help on this.

Why is delegate.BeginInvoke erring on the UWP Platform?

$
0
0

This is my first attempt at implementing an asynchronous delegate. So, maybe I'm doing something incorrectly. However, this works just fine for my Android project. But, when I run this on my UWP project, I get a PlatformNotSupportedException. Does the UWP platform not support this .Net C# library method? If I change this delegate back to synchronous and call the Invoke method, I have no problems. But, the underlying method that the delegate calls is an asynchronous method, so I think I need to make the delegate asynchronous to make it thread safe. At least, that is my understanding.

    private void ChangeCompletedManifest(TPSArgs tpsArgs)
    {
               _changeManifestRecord.BeginInvoke(tpsArgs, new AsyncCallback(CallbackMethod), _changeManifestRecord);
     }

    private void CallbackMethod(IAsyncResult result)
    {
        ManifestPage.ChangeManifestRecord changeManifest = (ManifestPage.ChangeManifestRecord)result.AsyncState;
        changeManifest.EndInvoke(result);
    }

Xamarin.iOS Custom url schemes

$
0
0

I am doing Xamarin.Forms app with deep linking but when I click on certain url link
method in PCL project in App.xaml.cs named: protected override void OnAppLinkRequestReceived(Uri uri) is never called.
So the link is opening with a browser.

So I started to make a workaround with custom implementation on Android and iOS project, and everything works fine on Android but on iOS it does not work.
Can someone see did I miss something?

Link is always opened with a browser.
On Android it is working fine but on iOS it does not.
Here are two pictures from AppDelegate.cs and Info.plist, did I miss something?
Breakpoint is also never hit.
When I click on url https://strukturnifondovi.hr in contacts app in iPhone simulator it always open a browser.

Viewing all 79144 articles
Browse latest View live