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

Should I always write PushAsync / PopAsync inside Device.BeginInvokeOnMainThread?

$
0
0

What I do not like: I can't handle or wait the result. For example, I can't prevent calling PushAsync/PopAsync twice with very small delay

public void AddPage(Page page)
{
    var nav = (Application.Current.MainPage as NavigationPage).Navigation;
    if (nav.NavigationStack.Count == 0 || nav.NavigationStack.Last().GetType() != page.GetType())
    {
        Device.BeginInvokeOnMainThread(async () => await nav.PushAsync(page));
    }
}

If I call this method 2 times in a row, NavigationStack will be checked 2 times, then PushAsync will be called 2 times.

Should I also set Application.Current.MainPage, MasterDetailPage.IsPresented and so on inside Device.BeginInvokeOnMainThread ? Where is the full list?


.NET Standard lib PDFSharp

$
0
0

Hi, I'm trying to use the PDFSharp.netstandard2.0 and the many version that are similar to generate a pdf file into .NET standard 2.0 library that will be later used on both Xamarin.IOS and Xamarin.Android, but it faile when trying to load System.Drawing.FontFamily

According to this: apisof.net/catalog/System.Drawing.FontFamily (sorry remove the http protocol in front so I can post this)
I would need the .NET Standard + Platform Extensions (which I have no clue where I can find the platforms extensions that would provide this).

It always throw when entering into a function that create an XFont on the stack with the following error:
`Unhandled Exception:

System.TypeLoadException: Could not load type of field 'PdfSharp.Drawing.XFont:_gdiFontFamily' (14) due to: Could not resolve type with token 01000050 from typeref (expected class 'System.Drawing.FontFamily' in assembly 'System.Drawing.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:System.Drawing.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Drawing.FontFamily member:(null) occurred`

I check the following nuget packages:

  • Microosft.Windows.Compatibility
  • System.Drawing.Common
  • System.Drawing.Primitives

But I'm a little lost why the package doesn't pull the required dependencies in the first place and where I can find that System.Drawing.FontFamily for .NET Standard that is required to make the package work.

Text of button is not displaying?

$
0
0

Hi All,
I am facing an strange problem.
I have added an button inside a
But the problem I am facing is the button's text is not visible.Button is visible to me but Text is not showing for the button.
Does anybody is having any idea why this is happening?

How do I fix this Editor control behavior?

$
0
0

The following is the XAML that I have:

                <StackLayout Orientation="Horizontal">
                    <Editor x:Name="edtTaskDesc"
                            Text="This is a long test to test how it will be displaye in this Editor control in Xamarin Forms."
                            FontSize="Medium"
                            BackgroundColor="LightBlue"
                            HorizontalOptions="FillAndExpand"
                            HeightRequest="80" />
                    <StackLayout HorizontalOptions="End">
                        <Label x:Name="lblDescCharCount"
                               Text="50"
                               BackgroundColor="LightBlue"
                               HorizontalTextAlignment="Center"
                               VerticalTextAlignment="Center"
                               FontSize="Medium" />
                        <Button x:Name="btnPhoneCallType"
                                Text="T"
                                BackgroundColor="LightBlue"
                                HeightRequest="48"
                                WidthRequest="48" />
                    </StackLayout>
                </StackLayout>

When I remove the Text - "...….", the controls are displayed as in the below screenshot and when I type in the text aptly wraps around as required.

But with Text pre-filled as in the above XAML, the inner StackLayout pushed off the display as shown in below screenshot.

What am I doing wrong? I want the Text to wrap around on pre-fill also as eventually I will be binding to a View Model.

How to connect via bluetooth to a Raspberry

$
0
0

Hi all! I introduce myself, my name is Osvaldo, I was recently learning to use Xamarin C # (I only knew how to use Java), I'm doing a hybrid application where from an iPhone or an Android phone can connect via bluetooth to a Raspberry pi zero w, the application has worked but only to a certain extent, first I commented that the application reads LE devices, but not the Raspberry, second the application is only working so far on Android and I do not know why it does not work on IOS, and third I have to extract from the Raspberry the SSID and the wifi password to which it is connected, if you can guide me and help me solve this, I would appreciate a lot !!!
PD: sorry for my English, but I'm still practicing.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using Plugin.BluetoothLE;

using Xamarin.Forms;

namespace GreenBooth
{
public partial class MainPage : ContentPage
{
IAdapter adapter;
ObservableCollection devices;
IDevice device;

    public MainPage()
    {
        InitializeComponent();
        adapter = CrossBleAdapter.Current;
        devices = new ObservableCollection<IDevice>();
        DevicesList.ItemsSource = devices;
    }
    /*---------------------------------------------------------------*/
    public async void searchDevice(object sender, EventArgs e)
    {
        devices.Clear(); //limpiamos el contenedor de los dispositivos cada vez que hacemos una busqueda//
        if (adapter.Status == AdapterStatus.PoweredOff)
        { //verificamos si el adaptador de bluetooth esta desactivado, tambien puede verificar otros estados//
            await DisplayAlert("Atencion!!!", "Bluetooth esta desactivado", "OK");
        }
        else
        {

            var scanner = CrossBleAdapter.Current.Scan().Subscribe(scanResult =>
            { //scanResult almacena el dispositivo, el RSSI y el packete de anuncio //

                if (!devices.Contains(scanResult.Device))
                {
                    devices.Add(scanResult.Device);
                }
            });

        }
    } //----------------Fin busqueda dispositivos------------//
    private async void DevicesList_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
    {
        device = DevicesList.SelectedItem as IDevice;

        var result = await DisplayAlert("AVISO", "Desea conectarse a este dispositivo???", "Conectar", "Cancelar");

        if (!result)
            return;
        try
        {

        }
        catch (Exception ex)
        {
            await DisplayAlert("Error de conexion", ex.Message, "OK");
        }

    }
    private async void Salir(object sender, SelectedItemChangedEventArgs e)
    {
        System.Diagnostics.Process.GetCurrentProcess().Kill();
    }
}

}

How I can print Text and Image in a normal printer?

$
0
0

Hi everyone,

I'm trying to print text and image in a normal printer, not POS or Zebra printer.

The printer is a Canon Pixma MX351.

I want to print wifi or bluetooth way, but I can't found a resource to help me.

Someone of you have done this or have an idea of ​​how I can connect to these devices and be able to print?

I'm working with xamarin forms.

Thanks in advance!

How to post the data to json uri?

$
0
0

I can able to read the data from the URI using listview and I don't know how to post the data from listview to JSON I had searched internet lot but I can't clearly understand these things please guide me.

`Code for get data from uri(json) : working fine
public async Task GetAsync(string uri)
{
using (HttpClient client = new HttpClient())
{
var request = new HttpRequestMessage()
{
RequestUri = new Uri(uri),
Method = HttpMethod.Get
};

            var response = await client.SendAsync(request);
            return JsonConvert.DeserializeObject<T>(response.Content.ReadAsStringAsync().Result);
        }
    }`

`Code to post data to uri

public async Task PostAsync(string uri, object param, Dictionary<string, string> headers = null)
{
using (HttpClient client = new HttpClient())
{
StringContent content = new StringContent(JsonConvert.SerializeObject(param), Encoding.UTF8, "application/json");

            if (!Equals(headers, null))
            {
                foreach (var header in headers)
                {
                    content.Headers.Add(header.Key, header.Value);
                }
            }

            var request = new HttpRequestMessage()
            {
                RequestUri = new Uri(uri),
                Method = HttpMethod.Post,
                Content = content
            };

            var response = await client.SendAsync(request);
            return JsonConvert.DeserializeObject<T>(response.Content.ReadAsStringAsync().Result);
        }
    }

`
Please guide me to post data in json uri

App does not fill 18:9 display

$
0
0

Hey, everyone. This weird behavior has been happening on my app on a device with a 18:9 display aspect (Xiaomi Mi A2 Lite)
As you can see, the app doesn't fill the screen entirely, and I couldn't figure out how to fix it.

These are my packages versions:

"Xamarin.Forms" Version="3.1.0.697729"
"Xamarin.Android.Support.Design" Version="27.0.2"
"Xamarin.Android.Support.v7.AppCompat" Version="27.0.2"
"Xamarin.Android.Support.v4" Version="27.0.2"
"Xamarin.Android.Support.v7.CardView" Version="27.0.2"
"Xamarin.Android.Support.v7.MediaRouter" Version="27.0.2"

I've tried to update to Xamarin.Forms 3.4 but nothing changed.
Also, I have other apps running on the same device, and they fit perfectly on screen.

Has anyone ever faced something like that?


Method 'Android.Support.V4.View.ScaleGestureDetectorCompat.SetQuickScaleEnabled' not found

$
0
0

Hi,
All I tried to do is implementing PinchGesture. the app compiled and worked fine, the moment i start pinching, it breaks and shows the subject message error exception.
My target is 8.1 Oreo,
Linking Assembly is set to None,
Android.Support.V4 => 27.0.2.
Xamarin.forms V.3.4.0
What could be the reasons for this ???

ABRIR LINK EN EL NAVEGADOR MEDIANTE ESCANEO DE CÓDIGO QR

$
0
0

Tengo como proyecto universitario realizar una app que sirva para abrir archivos en la web mediante el scaneo de codigos QR CON LA CAMARA DEL SMART PHONE (ANDROID/IOS) eh escogido XAMARIN para el desarrollo de esta app lamentablemente mi conocimiento es muy poco ... ES POSIBLE HACER ESTO ? ... alguien conoce el link de algún código?

Weird Margin for sliders on Android

$
0
0

The slider on android has a horizontal margin that is not present in iOS (I have xaml code below to show what i am talking about). Everything else seems to align properly and changing the margin, padding and horizontalOptions for the Slider (and StackLayout) doesn't fix this problem.

I am not that familiar with Xaml or Android's material design UI, so I may be missing something obvious. If not, is this the place where I need a custom renderer?

<StackLayout Padding="10" BackgroundColor="Gray">
        <Button/>
        <StackLayout Orientation="Horizontal">
            <Slider HorizontalOptions="FillAndExpand"/>
            <Button HorizontalOptions="End"/>
        </StackLayout>
        <Slider HorizontalOptions="FillAndExpand"/>
        <Label Text="Ipsem"/>
</StackLayout>

MVVM: How do I reset a picker's index?

$
0
0

Hi,
I have a picker with a static list of items. The user can select an item and it adds it to the page. Now, when the user swipes left or right, I need to reset the picker's index back to what it was originally. How would I go about that? I tried setting the bound property to the same list of items, but that didn't seem to do it. Thanks.

Image display different using resource or stream

$
0
0

I'm trying to display an image read from stream.

I have a form with an Image View.

If I use:

ImageSource = "name.png"

where name.png is the name of a resource in android drawable, the image display correctly (it expands on the image area)

If I use:

ImageSource = ImageSource.FromResource("name1.png")

where name1.png is a resource in the shared assembly (a copy of the image in android drawable), the image is stretched (don't fit to view area) to top center of the image area.

I have the same behaviour if I read an image in a stream and I use ImageSource.FromStream().

The Image view set a VerticalOptions="StartAndExpand" (Aspect and HorizontalOptions are unsetted)

Any hints?

新西兰林肯大学文凭毕业证成绩单Q/微信9105133英国林肯大学毕业证成绩单*学位证书文凭学历认证/留信网认证/使馆认证公正Lincoln University

英国温切斯特大学文凭毕业证成绩单Q/微信9105133英国温切斯特大学文凭毕业证成绩单*学位证书文凭学历认证/留信网认证/使馆认证公正The University of Winchester


英国北安普顿大学文凭毕业证成绩单Q/微信9105133英国 UoN毕业证成绩单学位证书文凭学历认证/留信网认证/使馆认证公正The University of Northampton

英国诺丁汉特伦特大学文凭毕业证成绩单Q/微信9105133英国 NTU毕业证成绩单学位证书文凭学历认证/留信网认证/使馆认证公正Nottingham Trent University

英国诺森比亚大学文凭毕业证成绩单毕业证成绩单Q/微信9105133英国 NU毕业证成绩单学位证书文凭学历认证/留信网认证/使馆认证公正Northumbria University

英国约克圣约翰大学文凭毕业证成绩单Q/微信9105133英国约克圣约翰大学文凭毕业证成绩单*学位证书文凭学历认证/留信网认证/使馆认证公正York St. John's University

英国哈德斯菲尔德大学文凭毕业证成绩单Q/微信9105133英国 HUD毕业证成绩单学位证书文凭学历认证/留信网认证/使馆认证公正University of Huddersfiel英国哈德斯菲尔德大学文

Viewing all 91519 articles
Browse latest View live


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