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

Any tools or libs for displaying an offline map using local vector mbtiles?

$
0
0

Are there any tools or libs for displaying an offline map using local vector mbtiles file stored on device?
(I use mbtiles from openmaptiles.com.)

I've tried tried MapsUI but it only support raster tile.

Any suggestion?

Thanks


Xamarin Forms QR code scanner blank screen

$
0
0

I have a Xamarin Forms 2.0 application that uses ZXing.Net.Mobile and ZXing.Net.Mobile.Forms version 2.0.3.1. I'm trying to build a simple QR code scanner, but whenever I launch the ZXingScannerPage on Android I can see the default overlay (with the text and the red line) but I don't see the output of the camera so I can't actually scan anything. I have already listed the Camera permission in my AndroidManifest:

I tried the sample code from the readme: https://github.com/Redth/ZXing.Net.Mobile as well as from their Samples/Forms project. I now have this code:

`private async void OnScanQrClicked(object sender, EventArgs e)
{
_scannerPage = new ZXingScannerPage();
_scannerPage.OnScanResult += HandleScanResult;

await Navigation.PushAsync(_scannerPage);

}

private void HandleScanResult(Result result)
{
_scannerPage.IsScanning = false;

Device.BeginInvokeOnMainThread(() =>
{
    Navigation.PopAsync();
    DisplayAlert("Scanned code", result.Text, "OK");
});

}`

Some more specs: I'm running Android 5.1 on a Moto G (v1).

Why am I not seeing the output of the camera?

Is there a Clipboard plug-in/component for Xamarin.Forms?

$
0
0

I need to implement Copy to Clipboard within my app. Is there a component/plug-in to support this, or am I back to writing more DependencyServices?

Thanks,

John H.

Accessing Phone contacts and send sms

$
0
0

What's the best way to access the phonebook and send sms to a contact on Xamarin.Forms. Is there any good package or plugin fro Xamarin.Forms I can use to accomplish this task? Keep in mind I want it to be cross-platform. Thank you in advance for the replies.

Trouble with Binding Can get but can't set

$
0
0

Hi guys,

I am new to XF and just trying to learn Binding a bit.

In my XAML, I have the following label:

<Label HorizontalOptions="Center" VerticalOptions="Center" Grid.Column="0" Grid.ColumnSpan="3" Text="{Binding Credit}" />

and in the code behind, I have the following:

              private string credit { get; set; } 
              public string Credit  {
                        get
                        {
                            return credit; 

                        }
                        set
                        {
                            credit = value;
                    }
                             }

So when I set an initial value, for example, credit = "0.00" it works perfectly fine but my problem is setting it:

   private void Button_OnClicked(object sender, EventArgs e)
        {
        var crdString = Credit;

            float crd = float.Parse(crdString);
            crd++;
            credit = crd.ToString();
        }

But it does not update the UI.

P.S I have also set the BindingContext :

        InitializeComponent ();
            BindingContext = this;

xam.plugin.media not working on Android (Works on UWP)

$
0
0

xam.plugin.media not working on Android (Works on UWP)

I've started xamarin forms recently and have been trying to get xam.plugin.media to work. I scoured the web and am at the end of my wisdom.

I'm checking if I have permissions, a camera is available, photo is supported and even then it crashes.
Plugins were implemented as stated by the readme and/or fellowbloggers.
Permissions set in my xamarin liveplayer device.

Even tried example solutions but since they are usually out of date and xamarin aswell as the plugin doesnt quite like that they didnt work aswell.

Solution github.com/peyter213/xam_plugin_media-Issue

Thanks to anyone that dares to take a look.

Error: i.imgur.com/GrarxPq.png

Codeexample of the MainPage

MainPage.xaml.cs
` private async void Btn_takePhoto_Clicked(object sender, EventArgs e)
{
try
{
var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Camera))
{
await DisplayAlert("Camera Permission", "Allow SavR to access your camera", "OK");
}

                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera });
                status = results[Permission.Camera];
            }

            if (status == PermissionStatus.Granted)
            {

                await CrossMedia.Current.Initialize();

                if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
                {
                    await DisplayAlert("No Camera", ":( No camera available.", "OK");
                    return;
                }
                var s = CrossMedia.Current.IsCameraAvailable;
                var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    PhotoSize = PhotoSize.Medium,

                });

                if (file == null)
                    return;
            }
            else if (status != PermissionStatus.Unknown)
            {
                await DisplayAlert("Camera Denied", "Can not continue, try again.", "OK");
            }
        }
        catch (Exception ex)
        {

            await DisplayAlert("Error", "Camera Not Available", "OK");
        }
    }`

How to use ClassId

$
0
0

Hi,
I'm trying to do an alternative ListView where I want to be able to change and update labels after the "cells" are created. This is my first test, just put alot of stacklayouts in a scrollview. The problem is that I cant figure out how to change the ".Text" parameter for the labels based on their ClassIds.
This simple test should work as that if I click on for example the button with the ClassId "1" the Text of the Label with the ClassId "lbl1" should change to "Hello". So I guess the main question is how to reference an item based on it's ClassId? Hope this makes some sense..

Best regards
Magnus

using System;
using Xamarin.Forms;

namespace TestScroll2
{
    public partial class TestScroll2Page : ContentPage
    {
        StackLayout mainLayout;
        public TestScroll2Page()
        {
            mainLayout = new StackLayout
            {
                Margin = new Thickness(0, 0, 0, 0)
            };

            for (var i = 0; i < 40; i++)
            {
                var stackLayout = new StackLayout();
                stackLayout.ClassId = "Stack" + i;

                var stackLabel = new Label()
                {
                    Text = "Separators in stack layout " + i
                };
                stackLabel.ClassId = "lbl"+i;
                var stackButton = new Button()
                {
                    Text="Click Me"
                };
                stackButton.ClassId=""+i;
                stackButton.Clicked += OnButtonClicked;

                stackLayout.Children.Add(stackLabel);
                stackLayout.Children.Add(stackButton);

                stackLayout.BackgroundColor = Color.Gray.MultiplyAlpha(0.2);

                mainLayout.Children.Add(stackLayout);
            }

            Content = new ScrollView() { 
                Margin = new Thickness(0, 30, 0, 0),
                Content = mainLayout 
            };
        }
        void OnButtonClicked(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            StackLayout stl = (StackLayout)btn.Parent;
            DisplayAlert("Alert", "OnButtonClicked: "+btn.Parent.ClassId , "OK"); // this works
            //this.FindByName<Label>("lbl1").Text="Hello"; -> this is where I like to update the corresponding label
        }
    }
}

missing templates in visual studio

$
0
0

hi,
i have visual studio enterprise 2017 and i installed all the things to be worked with xamarin.
i did it maybe 5 times in two weeks and im getting crazy.
when i choose in visual studio file->new->project, i choose in the left pannel for c#, cross platform

i have only two options:
1)UI Test APP
2)class library(xamarin forms)

everyone i know include posts at the internet have a third option:
3)Cross platform App(xamarin forms or native)

which is the exactly i need!

when i choose the second option i can choose between shared project or .net standard. this thing its only in my computer
everyone else has portable class instead of the .net standard option and i need the poratable!

what do i need to install to have the third options?
i've been trying to seek for this two weeks

please help!!!


i have problem with creating a custom markup extension

$
0
0

i am trying to learn Xamarin by reading Ceating mobile apps with Xamarin Forms. Page 210 explain how to link Xamarin.FormsBook.Toolkit to CustomExtensionDemo project. I follow instructions(Include a link to the library project in your application solution, and add a reference to that library project in the common PCL project.) but Xamarin studio says FormsBook doesn not exist in the namespace. I have created Markup extension and CustomExtensionDemo project. there is also link in project. new Xamarin.FormsBook.Toolkit.HslColorExtension(); nevertheless it gives error message. i don't know how to reference to that library project in the common PCL project perhaps

Hints for 'InflateException' in XF app using an Android AXML for one activity

$
0
0

So I'm working on a Xamarin.Forms app.
While importing an vendor's SDK the make a separate Android Activity that inflates its own UI for a period of time. Kind of like when you click a [camera] button in an app, then another camera view is generated until you take the picture, then goes away returning you to your app.

The vendor sample app works. When importing their elements to my project the same Activity and AXML crashes with an Android Inflate Exception.
Clearly I'm missing some part, reference, or XML style reference. But that exception give no hint, no idea, nothing helpful like "style blahblah could not be found" or "element with @+id/buttonimage" could not be found" etc.

Does anyone know a way to get some more info out of the android side of the app during run-time debugging? This vague message is not helpful at all.

Xamarin Forms Map - How to know when the map is full loaded and displayed?

$
0
0

Hi,

I really need to know when the map is either full loaded or displayed but I cannot find anything anything about it, why?

Do you have any idea about an event or something like that?

Thank for any help !

Xamarin Forms UWP - MapIcon/Pins size

$
0
0

My question cannot be more easy:

How can I change the size or resize my pins about the zoom?

This is for a CustomPinRenderer of my UWP part. (PCL project)

Scrolling Grid Relative Sizes

$
0
0

I have managed to create a GridView inside a ScrollView that uses 8 rows of row height 250 (Absolute). This was fine until I realised it would not work on screens with different resolutions. How can I create a grid view where there are 8 rows, but each row takes up half the screen so you have to scroll down to see the rest? Using 8 rows of height "*" just puts 8 rows onto the view with no scrolling. I am using xaml but can use c# if necessary.

ios xamarin live player

$
0
0

how to connect my app with a database ?

Can't Compile Release with .NET Native tool chain Error MSB3073 exited with code 1201

$
0
0

I have been developing an App for the windows store UWP Windows 10. In debug mode with "Compile with .NET Native tool chain" turned off.

Now its time to build the release and upload to the store and I get the following compilation error.

1>MSBUILD : error : System.NotSupportedException: Cannot deserialize type 'System.Exception' because it contains property 'HResult' which has no public setter.

1>MSBUILD : error : at System.Xml.Serialization.TypeDesc.CheckSupported()

1>MSBUILD : error : at System.Xml.Serialization.TypeDesc.CheckSupported()

1>MSBUILD : error : at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)

1>MSBUILD : error : at System.Xml.Serialization.ReflectionAwareCodeGen.WriteReflectionInit(TypeScope scope)

1>MSBUILD : error : at System.Xml.Serialization.XmlSerializationWriterCodeGen.GenerateBegin()

1>MSBUILD : error : at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Hashtable assemblies, String outputDir, String assemblyNameBase, IEnumerable 1 referenceDirectories, String intermediateDir, Boolean loadAssembly)

1>MSBUILD : error : ILT0032: Failed to compile serialization code. See the build log for error details.

1>MSBUILD : error : at System.Xml.Serialization.XmlSerializer.GenerateSerializer(Type[] types, XmlMapping[] mappings, CompilerParameters parameters, String outputDir, String assemblyNameBase, IEnumerable 1 referenceDirectories, String intermediateDir, Boolean loadAssembly)

1>MSBUILD : error : at System.Xml.Serialization.XmlSerializer.GenerateSerializer(Type[] types, String outputDir, String assemblyNameBase, IEnumerable 1 referenceDirectories, String intermediateDir, List 1 wcfSerializers, Boolean loadAssembly)

1> Done executing task "RunILTransforms" -- FAILED.

1> Done building target "RunILTransforms" in file "ILTransforms" -- FAILED.

1> Done building project "ILTransforms" -- FAILED.

1>MSBUILD : error : at SerializationAssemblyGenerator.Program.Main(String[] args) C:\Users\user.nuget\packages\microsoft.net.native.compiler\2.0.3\tools\Microsoft.NetNative.targets(741,5): error MSB3073:

The command C:\Users\user.nuget\packages\microsoft.net.native.compiler\2.0.3\tools\x86\ilc\ilc.exe @obj\x86\Release\ilc.MyApp.rsp /v:diag" exited with code 1201.

I am using XML and JSON Serialisation and Deserialisation in my code but it all seems correct.

The issue seems to be with the 'System.Exception' and its property 'HResult' which upon inspection seems to have a protected setter preventing deserialisation.

Any help in solving this would be fantastic.


Entity Framework App Not Launching

$
0
0

I added the binarys for entity framework into the standard master detail application but when I launch my app it just get stucks I have included a screen shot of my program to see if I have referenced everything correctly.

Please let me no if there is something I need to enable to get this working

Picker ItemsSource not binding

$
0
0

I'm attempting to bind a Picker to an ObservableCollection and nothing displays. I have set up a second property, CategoryCount, to return the count of the collection, which correctly shows 2.

    <StackLayout Spacing="20" Padding="15">
        <Label Text="Category" FontSize="Medium" />
        <Picker ItemsSource="{Binding CategoryList}"  ItemDisplayBinding="{Binding Name}" SelectedItem="{Binding Item.Category}" />
        <Label Text="Category Count"/>
        <Label Text="{Binding CategoryCount}"/>
    </StackLayout>


public class ItemDetailViewModel : BaseViewModel
 {
    public ObservableCollection<Category> CategoryList;
    public string CategoryCount
    {
        get
        {
            return CategoryList.Count.ToString();
        }
    }
    public LedgerEntry Item { get; set; }

    public ItemDetailViewModel(LedgerEntry item)
    {
        Item = item;
        CategoryList = new ObservableCollection<Category>()
        {
            new Category(){Id = 1, Name="test"},
            new Category(){Id = 2, Name = "hallo"}
        };
        OnPropertyChanged("CategoryList");
    }
}


public class Category
  {
     public int Id { get; set; }
     public string Name { get; set; }
  }

I've tried changing it to a List of strings with proper values, and could not get that working either. Any thoughts on why I'm having this issue?

How to open navigation Page in Listview local:view ?

$
0
0

<DataTemplate> <StackLayout HorizontalOptions="FillAndExpand" BackgroundColor="White"> <local:NewListView/> </StackLayout> </DataTemplate>
In NewListView.xmal.cs
<Image Grid.Column="13" Source="Reply_UnChecked.png"> <Image.GestureRecognizers> <TapGestureRecognizer Tapped="OnClickReply" NumberOfTapsRequired="1" /> </Image.GestureRecognizers> </Image>
In NewListView.cs
private void OnClickReply(object sender, EventArgs e) { var page = new ReplyPage(); Navigation.PushAsync(page); System.Diagnostics.Debug.WriteLine("Replay Page Open"); }
when i tapped OnClickReply the Debug was showed but the page did not create and open

I already tried await navigation.pushasync but also did not open new page.

I think the local:??? is in listview, so the navigation.pushasync is not work.

How can i create and open the new page when upper case?

Sample for socket application

$
0
0

I need simple sample for socket in Xamarin Forms.

Dynamically changing editor height to accommodate multiple lines of text as needed

$
0
0

I want my editor to behave like the iOS messages app: at first it's just a single line, but as you type enough to add another line, the editor expands and its Y coordinate moves up (so that it doesn't fall offscreen). I read https://forums.xamarin.com/discussion/99124/how-to-show-multiple-lines-in-an-editor and it almost works. The biggest issue I have right now though is that the vertical centering gets screwed up. Here's what happens:
1. Initial startup, editor is sized correctly for a single line
2. Type enough to form a second line. The editor does correctly increase its height, however, now the vertical centering is screwed up. Text is top aligned.
3. Keep typing enough to add a 3rd line. As expected, height correctly changes, but now the text is correctly center aligned vertically
4. Keep typing enough to add a 4th line. Vertical centering screws up as in #2. The pattern keeps repeating: we keep alternating between correctly aligned (center) and top.

Attached are images for states 1, 2, 3 for a more illustrative example.
The code is very simple (as that link shows): the custom editor just simply does InvalidateMeasure when the text changes.

Once I get past that issue, my second issue is that I don't know how to make its Y coordinate adjust upward. In my test I made a grid with 2 rows 1 column (as that link suggested sticking your custom editor in an autosizing grid row). First/top row is a box view which I set a HeightRequest to 500. Second/bottom row is the editor which I didn't set any height values for. In reality the box view will be replaced with a different view, like a list or something, but box seemed easiest to test with. Anyway, the desired behavior is the same as the iOS message app: instead of the text box height expanding downward, the Y coordinate moves up and the height expands, so that the net effect is the box just grows taller (upward) and not downward. I would be OK with either the editor expanding upward and partially obscuring the contents above it, or with the layout adjusting both items so that the height of the upper row shrinks as the height of the lower (editor containing) one expands. Either works just as well.

Viewing all 58056 articles
Browse latest View live


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