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

Xamarin Forms Android App Connect/Communicate via USB to PC

$
0
0

Hello,
I am working on an Android (Xamarin Forms) application, and have a need to communicate with a Windows PC. This communication NEEDS to happen over USB cable. I googled this problem and found a couple of incredibly similar projects anotherlab's UsbSerialForAndroid, and lusovu's XmarinUsbSerial.

I am using anotherlab's project as a starting point on how to get android -> pc usb comms working, but am running into the problem of never being able to find any devices when the tablet is plugged into the PC. I have tried using a regular USB cable as well as an OTG cable without any luck. I just can't figure out why the device list is empty when using the following lines of code:

    usbManager = GetSystemService(Context.UsbService) as UsbManager;
    IDictionary<string, UsbDevice> devices = usbManager.DeviceList;

I'm thinking it might be a problem with the drivers it's using but I have no clue as to how to get the vendor id or the product id of the usb host controller in my laptop (done a quick search). Could it be something else?

I can connect to an Arduino device using the OTG cable and can get the project working with it, but I need it to work with a PC not an Arduino.

If anyone has any ideas I would be grateful,
Thanks


Xamarin.LiveReload 0.4.0 not showing in NuGet

$
0
0

YES, "Include prerelease" checkbox button is Enabled

I closed all VS instance and run VS again several time with no luck.. still shows 0.3.27 without 0.4.0

Please help

I also updated my Xamarin.Forms version to 3.1.0 (pre-release)

Embedded Image isn't loading

$
0
0

I'm trying out embedded images. First I get constantly "MarkupExtension not found for local". This is fixed it seems. My image is still not loading.
What am I doing wrong?
Some noob questions:
What assembly should I reference on this line?
xmlns:image="clr-namespace:Images"
What is the path to my image? Is correct?

I'm so confused and frustrated by all the erros I saw the last couple days.

This is my code: imgur . com/a/3id7ntu

using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Images{
    [ContentProperty(nameof(SourceID))]
    public class ImageResourceExtension : IMarkupExtension
{
    public string SourceID { get; set; }

    public object ProvideValue(IServiceProvider serviceProvider)
    {
        if (SourceID == null)
        {
            return null;
        }

        // Do your translation lookup here, using whatever method you require
        var imageSource = ImageSource.FromResource(SourceID);

        return imageSource;
    }
}
}

   <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="xamarin.com/schemas/2014/forms"
                 xmlns:x="schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:local="clr-namespace:App4"
                 xmlns:image="clr-namespace:Images"
                 x:Class="App4.MainPage">

        <StackLayout>
            <!-- Place new controls here -->
            <Image Source="{image:ImageResource App4.  scooter  .   png}" />


        </StackLayout>

    </ContentPage>

Bind Table

$
0
0

Hi xamarin forum how can I or rather what is the proper to call table from database to bind it to ListView should I do it like this

as a side note TableName.Customer is the format of my table's name

How to not show separator/divider row between rows in a ListView()

$
0
0

Hi, I'm using Xamarin forms to show a ListView(), everything is working fine, but I cannot find out a solution to not show separator/divider row between rows in my ListView.

Someone knows how to fix that?

Thanks so much.

How to call back a function within a custom ViewRenderer?

$
0
0

I created a custom renderer (called HybridWebViewRenderer) subclassed from the ViewRenderer class.

From the PCL, I have a ContentPage with a button and a HybridWebView.

From the PCL, I want to be able to call a function thats in the HybridWebViewRenderer class so that I can do some work with the webview.

How can I call the function?

FloatingActionButton renderer error...

$
0
0

Hello guys, I need some help to fix an issue here... I need to implement a FAB button to my application, and after some search in the Nuget, I choose from SuaveControls solution... In this package I got 2 problems, the package is deprecated, and the render result (only in Android) is looking like the image attached.

I try different things but nothing happens, the image (icon) isn't applyed to the button and its size doesn't changes...

The render is bellow:

public class FloatingActionButtonRenderer : Xamarin.Forms.Platform.Android.AppCompat.ViewRenderer<FloatingActionButton, FAB>
{
    public static void Initialize() 
    {
    }

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

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

        if (e.NewElement == null) return;

        var fab = new FAB(Context);
        // set the bg
        Android.Support.V4.View.ViewCompat.SetBackgroundTintList(fab, ColorStateList.ValueOf(Element.ButtonColor.ToAndroid()));
        fab.UseCompatPadding = true;

        // set the icon
        var elementImage = Element.Image;
        var imageFile = elementImage?.File;

        if (imageFile != null)
        {
            fab.SetImageDrawable(Context.GetDrawable(imageFile));
            //SetFabImage(imageFile);
        }
        fab.Click += this.Fab_Click;
        SetNativeControl(fab);
    }

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

    protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        var fab = (FAB)Control;
        if (e.PropertyName == nameof(Element.ButtonColor))
        {
            Android.Support.V4.View.ViewCompat.SetBackgroundTintList(fab, ColorStateList.ValueOf(Element.ButtonColor.ToAndroid()));
        }
        if (e.PropertyName == nameof(Element.Image))
        {
            var elementImage = Element.Image;
            var imageFile = elementImage?.File;

            if (imageFile != null)
            {
                fab.SetImageDrawable(Context.GetDrawable(imageFile));
                //SetFabImage(imageFile);
            }
        }
        base.OnElementPropertyChanged(sender, e);

    }

    private void Fab_Click(object sender, EventArgs e)
    {
        // proxy the click to the element
        ((IButtonController)Element).SendClicked();
    }
}

Do you have any tip or help to me?

Best regards,
Alex Florindo

Look for example of xamarin form dish dishes on smartphone with SQL Server database

$
0
0

I'm looking for examples of xamarin form dishes on smarphones like cafes, restaurants, ... or example xamarin form that connects SQL Server data and output to listview, do you have share code for me ?


How to Scroll to Top on Filter of ListView?

$
0
0

I have a SearchBar which is used to filter a ListView of data. If I scroll to the bottom or middle of the ListView then start entering data in the SearchBar to filter the list, I want to be able to automatically scroll to the top of the ListView so that it shows items at the top as the filter as applied.

I was thinking to use the ScrollTo method of the ListView on the Textchanged of the SearchBar to just ScrollTo first item in the list, but not sure how to get the item object of the ListView. It's an IEnumberable so I can't index it to get say the first item in the list. Am I heading in the right direction or is there a different way to do this?

WiFiManager.ScanResults now work. error

$
0
0

I have two projects. The code for both projects is the same and the permission settings in AndroidManifest.xml are the same.
But one project works well. However, one project works fine and the other project always returns an empty list.

var wifiManager = (WifiManager)Android.App.Application.Context.GetSystemService(Context.WifiService);
IList<ScanResult> list = wifiManager.ScanResults;

ListView can make a phone call

$
0
0

Hi Xamarin Forum
may I ask if it is possible I have a list of contact made out of ListView then lets say I have a searchbar then I search for my ListView records for a contact then I will tap on the number in that listview is that possible? if it is possible how? can some one give an idea

ViewCell not dynamically adjusting height after contents changed.

$
0
0

I will change the Text of labelColor after the page re-appears from a color selection page. The label's contents change but are written into the cell below. If I force a refresh by moving the cell off screen, the cell adjusts correctly to the labels contents. How can I get it to display correctly or how can if programatically force the TableView to redraw/refresh? Thanks...








<Grid.RowDefinitions>

</Grid.RowDefinitions>
<Grid.ColumnDefinitions>



</Grid.ColumnDefinitions>

How to change the default icon of toolbar, when using toolbaritems with secondary order ??

$
0
0

I'm trying to create a toolbar in xamarin.forms.
I have added 3 toolbar items in it. All with order secondary.
It works correct, but by default it is having icon with 3 vertical dots.
I want to change this icon.
How can I change it ????

GPS Location Enable in Xamarin forms

$
0
0

In Xamarin forms ,I have to enable GPS like as below image not in settings page

Could you please suggest some samples to tapped page with MVVM?

$
0
0

In my app I am using tapped page and tapped page children has 3 content page.
First content page has some entry and add button.
Second content page has list view.
In first content page I am giving input and click add button.That giving input i want to show in second content page list view.
How to achieve this using MVVM?


Binding View Model to a grid.

$
0
0

I am really fade up with the grid. Don't know how to create a grid which will bind Images cause I don't know how many images are coming from API. I did this way -->

        <ListView x:Name="RecipeList" HasUnevenRows="True">

              <ListView.ItemTemplate>
                   <DataTemplate>
                      <ViewCell>

                            <Grid RowSpacing="0" Padding="5">
                             <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                <!--<RowDefinition Height="*"/>-->
                             </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                     <ColumnDefinition Width="*"/>

                            </Grid.ColumnDefinitions>

                                <StackLayout Grid.Row="0"  Grid.Column="0">

                                  <Image x:Name="imge1" Source="{Binding image}" HeightRequest="300" WidthRequest="300"     HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/>
                                 <Label x:Name="lbl_name"  TextColor="Black" Margin="0,-35,0,0"
                                 HorizontalOptions="CenterAndExpand" VerticalOptions="Start" LineBreakMode="TailTruncation" Text="{Binding title}"  FontFamily="Bold" FontSize="Medium"/>
                            </StackLayout>
                        </Grid>
                    </ViewCell>
                </DataTemplate>

            </ListView.ItemTemplate>

So it will bind the images repectively to row wise. So I want to fix that there should be two columns per row and both columns should have different image. But didn't find the way to implement that.

I am attaching an Image it will help to understand what actually I want to do.

Display all 3 parameters in listView

$
0
0

Hi Xamarin forum
how to display three parameters so that I can display it in ListView lest say I will want to display Name Address and Phone number I already Binded Name and Address using Text and Details of Text cell so how can I also Bind Phone

I have add a web service (asmx file , from the web) to my app and ai have a error

$
0
0

the error is "the type or namespace name 'services' does not exist in the name space 'system.web' (are you missing an assembly reference?

what the reference ii must have add to my project to work this file

Unhandled Exception: System.TypeLoadException: Could not resolve type with token 010000c1

$
0
0

Anyone having or ever had an issue with installing Xamarin Forms 3.0+ (or another version) and then the app starts crashing on the .init(..) line in the android activity on start up.

I am creating a blank project and updating XF to 3.0+ and this works fine, when I start adding packages and implement this in my activity in android I eventually get the exception and only works rolling back to XF's 2.5.

Any ideas how to debug this or preferably solve this issue. I am guessing this might be to do with a reference issue with one of my packages dependencies regarding Forms.

Error below:

Unhandled Exception:

System.TypeLoadException: Could not resolve type with token 010000c1 (from typeref, class/assembly Xamarin.Forms.Xaml.XamlResourceIdAttribute, Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null)

Unhandled Exception:

Full error:

System.TypeLoadException: Could not resolve type with token 010000c1 (from typeref, class/assembly Xamarin.Forms.Xaml.XamlResourceIdAttribute, Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null)

Same picker UI for android and IOS.

$
0
0

Is there any way to implement picker in such way that it looks same in android and IOS device.
1)In android picker open in the center of the screen.
2)In Ios picker open in the bottom of the screen.

I Want to implement like that it will look like same in both devices and open in the same way. Look and feel should be same in both devices/

Viewing all 89864 articles
Browse latest View live


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