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

Linking question

$
0
0

Trying to build Release. This is Xamarin forms 2.2.0.31.
Compiled against latest Xcode and iOS SDK. (9.3.1)

This error goes away when No linking is selected from the Compiler menu.
Error MT2002: Failed to resolve "System.Void CoreGraphics.CGRect::.ctor(System.Single,System.Single,System.Single,System.Single)" reference from "Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065" (MT2002) (iOS)


System.Convert.ChangeType() Fatal signal 6 (SIGABRT), code -6 in tid

$
0
0

Hi,

I try change value by System.Convert.ChangeType()

public object GetValue(dynamic value,Type propertyType)
{
try {
return System.Convert.ChangeType(value, propertyType);
}
catch (Exception ex)
{
//
}
}

I can not catch the Exception. Output says only Fatal signal 6 (SIGABRT), code -6 in tid
It gives the same error in all types. For example, the string, int, datetime etc.
Xamarin.Forms 2.2.0.31

Thanks.

AppResources in Android

$
0
0

Hi friends.

In XF I use something like

AppResources.AvviaLetturaQRCode

to have strings with Localization.

Is It possible to use AppResources on Android side so I can use AppResources.Resx and AppResources.it.Resx present in XF also in Android side?

Thanks

Help with Signature Pad

$
0
0

I am attempting to implement the Xamarin SignaturePad component into my android and iOS projects.
https://components.xamarin.com/view/signature-pad

Firstly I created an interface in my PCL

    public interface ISignatureService {

        Task<SignatureResult> Request(SignaturePadConfiguration config = null, CancellationToken cancelToken = default(CancellationToken));
    }

Android:

resolverContainer.Register<ISignatureService>(t => new SignatureService())

` public class SignatureService : ISignatureService {

    internal SignaturePadConfiguration CurrentConfig { get; private set; }
    private TaskCompletionSource<SignatureResult> tcs;


    internal void Complete(SignatureResult result) {
        this.tcs.TrySetResult(result);
    }


    internal void Cancel() {
        this.tcs.TrySetResult(new SignatureResult(true, null, null));
    }


    public virtual Task<SignatureResult> Request(SignaturePadConfiguration config, CancellationToken cancelToken) {
        CurrentConfig = config ?? SignaturePadConfiguration.Default;

        this.tcs = new TaskCompletionSource<SignatureResult>();
        cancelToken.Register(this.Cancel);

        Forms.Context.StartActivity(typeof(SignaturePadActivity));

        return this.tcs.Task;
    }
}`

` [Activity]
public class SignaturePadActivity : Activity {

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

        var signature = new SignaturePadView(this)
        {
            StrokeWidth = 3f
        };

        AddContentView(signature, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
    }
}`

This works. However, you don't get a save or cancel button. The docs give instructions on how to customize the view to add these buttons, but the samples do things like

            SetContentView (Resource.Layout.Main);

            SignaturePadView signature = FindViewById<SignaturePadView> (Resource.Id.signatureView);

and these resources do not exist in my project. Where do they come from?

Social media Plugin compatible with Xamarin.Forms

$
0
0

Has anyone used a social media plugin with Xamarin.Forms?

The social media plugin I am familiar with does not seem to support Xamarin
http://docs.oneall.com/services/implementation-guide/mobile-devices/

I am looking for any service or plugin that handles authentication and calls to the most common social media platforms(FB, TW, Google+) and is compatible with XamarinForms.

Back button in context menu

$
0
0

I have custom web view and context menu in web view. Context menu have item go to previous page. How implement go to previous page? In my app used mvvmcross.

Query data including image from json webservice and show in image-object (Xamarin.Forms)

$
0
0

Hi all

To show images from our central datastore in Xamarin.Forms is a "major case" for us to go with Xamarin.

I try now for day's to display an image in Xamarin - without success - I am desperate and have no Idea how to bring it to work :-(

I hope, that someone can show me the right way...

Description:

I have to query data (including images) from an existing (json) WebService .
The images are stored on a SQL-Server (not in file-system).
The WebService is built with vb.net and runs on a Windows-Server as Service.
To test the WebService we also have built a small Windows testclient.
To be able to send the images over json, we encode/decode the Byte-Array to string:

Encode (with .Default-Encoding, the image can be showed in a DataGidview of the Windows testclient):

  • cPFA_Grid_Foto = System.Text.Encoding.Default.GetString(dt.Rows(i).Item("PFA_Grid_Foto"))

Decode (in Windows-testclient):

  • dr(cField) = System.Text.Encoding.Default.GetBytes(reader.Value)
    In the Windows-testclient I can display the images in a DataGridView.

Xamarin.Forms:

  • I can query the data from WebService and retrieve the data.

  • I am not able to display the image-data in an image-object

  • In (Xamarin) System.Text.Encoding I don't have a .Default-Option

    => Therefore (and as I know, that .default should not be used), I have also have tried out .UTF8- and .UNICODE-en- and decoding
    Further I have tried submit the byte-array as byte-array (so that json convert it to a string)
    => With .UTF8 and .UNICODE the image can't displayed in the Windows-testclient

In Xamarin, I have the following code to show the data in an image-object:
Note:

Variable cFotoDefault is encoded with .default (can be displayed in Windows test-client -> in Xmarin I don't have a decoder .default)

Variable cFotoUTF8 is encoded with .UTF8 and I decode it also with .UTF8

Variable cFotoUNICODE is encoded with .UNICODE and I decode it also with .UNICODE

Variable cFotoArray is not encoded -> json does submit it as string

public class EmpfehlungDetails : ContentPage
        {
            Label TitelLabel;
            Label AdresseLabel;
            Image FotoAnzeige;
            Byte[] ImageFotoUnicode;
            public EmpfehlungDetails(Empfehlung eq)
            {
                Title = "Details zu Empfehlung";
                NavigationPage.SetHasNavigationBar(this, true);
                string cFirma1 = eq.cPAB_Firma.Trim();
                string cFirmenZusatz = eq.cPAB_FirmenZusatz.Trim();
                string cStrasse = eq.cPAB_Strasse.Trim();
                string cPLZ = eq.cPAB_PLZ.Trim();
                string cOrt = eq.cPAB_Ort.Trim();
                string cTelFestnetz = eq.cPAB_Kontakt_FestnetzNummer.Trim();
                string cTelMobile = eq.cPAB_Kontakt_MobileNummer.Trim();
                string cMail = eq.cPAB_Kontakt_Mailadresse.Trim();
                string cAdresse = eq.cPFA_Adresse.Trim();
                string cKundenNummer = eq.cPFA_Kundennummer.Trim();
                //
                // Foto-Felder
                string cFotoDefault = eq.bPFA_Grid_Foto;
                string cFotoUTF8 = eq.bPFA_Grid_FotoUTF8;
                string cFotoUNICODE = eq.bPFA_Grid_FotoUNICODE;
                string cFotoArray = eq.bPFA_Grid_FotoArray;
                //
                Byte[] ImageFotoDefault = Encoding.Unicode.GetBytes(cFotoDefault);
                // -> 11'520 Bytes (Foto zu MTC)
                //
                Byte[] ImageFotoUTF8 = Encoding.UTF8.GetBytes(cFotoUTF8);
                // -> 10'409 Bytes  (Foto zu MTC)
                //
                Byte[] ImageFotoUnicode = Encoding.Unicode.GetBytes(cFotoUNICODE);
                // -> 5'760 Bytes  (Foto zu MTC)
                //
                Byte[] ImageFotoArray = Encoding.UTF8.GetBytes(cFotoArray);
                // -> 7'680 Bytes  (Foto zu MTC)
                //
                TitelLabel = new Label { Text = "Anbieter: " + cFirma1, Font = Font.SystemFontOfSize(NamedSize.Large), TextColor = Color.Blue, BackgroundColor = Color.White };
                AdresseLabel = new Label { Text = cAdresse, TextColor = Color.Black, BackgroundColor = Color.White };
                // Tests
                //FotoAnzeige = new Image { Source = ImageSource.FromStream(() => new MemoryStream(ImageFotoUnicode)), WidthRequest = 100, HeightRequest = 100, BackgroundColor = Color.Aqua, };
                // => No crash, Image is not shown
                FotoAnzeige = new Image { Source = ImageSource.FromStream(() => new MemoryStream(ImageFotoUTF8)), WidthRequest = 100, HeightRequest = 100, BackgroundColor = Color.Aqua, };
                // => No crash, Image is not shown
                //
                // FotoAnzeige = new Image { Source = ImageSource.FromStream(() => new MemoryStream(ImageFotoArray)), WidthRequest = 100, HeightRequest = 100, BackgroundColor = Color.Aqua, };
                // => Crash
                //
                // Test with URI that works
                //Uri link = new Uri("http://www.matso.ch/about/Kernkompetenzen.jpg");
                //FotoAnzeige = new Image { Source = ImageSource.FromUri(link), WidthRequest = 100, HeightRequest = 100, BackgroundColor = Color.Aqua, };
                //
                Content = new ScrollView // Nötig, damit die Seite gescrollt werden kann!
                   {
                       HorizontalOptions = LayoutOptions.Fill,
                        Orientation = ScrollOrientation.Vertical,
                       Content = new StackLayout
                     {
                         Spacing = 5,
                         Padding = 5, // Abstand zwischen den Elementen
                         VerticalOptions = LayoutOptions.Start, // Start der Anzeige oben -> funktioniert bei WP nicht (zentriert)
                         Children =
                {
                TitelLabel,
                FotoAnzeige,
                AdresseLabel,
                }
                     },
                   };
            }
        }

Questions:

- Is the code O.K. to show an Image from stream (should the code work in principal)?

- Do I miss something?

- Do I have to change something in the WebService - if yes - what?

Thanks a lot for any feedback.

Printing on iPad from WebView

$
0
0

Hello guys,

I want to print a webview with the default printer functionalities which are available on both Android and iOS. I have a DependencyService with a Print method, which calls the platform specific code to access the printing functionalities. The problem is that it is not working on iPad, but it works on Android and iPhones.

The code for iOS is the following:

UIWebView platformWebView = (UIWebView)webView.PlatformControl;

UIPrintInteractionController printer = UIPrintInteractionController.SharedPrintController;

printer.ShowsPageRange = true;

printer.PrintInfo = UIPrintInfo.PrintInfo;
printer.PrintInfo.OutputType = UIPrintInfoOutputType.General;
printer.PrintInfo.JobName = name;

printer.PrintPageRenderer = new UIPrintPageRenderer()
{
    HeaderHeight = 40,
    FooterHeight = 40
};
printer.PrintPageRenderer.AddPrintFormatter(platformWebView.ViewPrintFormatter, 0);

printer.Present(true, (handler, completed, err) =>
{
});

I now that the printer.Present function is primary made for iPhones (http://iosapi.xamarin.com/?link=M:UIKit.UIPrintInteractionController.Present) but it should work when you use True als the first parameter (that's also conform the documentation, not in the doc at the link, but visible when you press F12 on the method in Visual Studio). The problem is that nothing is happening on the iPad when I call this method. No error, nothing.
I am aware of the method printer.PresentFromRectInView, but I don't know what I need to pass as the first two parameters (http://iosapi.xamarin.com/index.aspx?link=M:UIKit.UIPrintInteractionController.PresentFromRectInView).

Does anyone have a working printing solution for iPad?

Thanks in advance.

Regards,
Gerco


Device.StartTimer and Application lifecycle

$
0
0

Hi my friends.
I've a Page with a Device.StartTimer that, every 60 seconds, try to connect to a NTP server and update a "label" with DateTime.
I would like to know if I have to do "something" for the Timer when the app is in "OnSleep" (stop the timer....) or Xamarin Forms handles the timer correctly. I don't know if the timer continue to "run" when the App is "OnSleep"...
Can someone explain how it works?
Thanks
Alessandro

how can i pass a string data from c# to WebView ?

$
0
0

I'm using a WebView that hosting a local Html file . i want to control in the content of local html using c#
for example i want to pass a list of string data to webview and display them as a list of paragraph tags (

<

p>) inside html file
how can i do that ?

Signature Pad in Android via Custom Renderer approach

$
0
0

I was able to use the Custom renderer approach, in Xamarin forms to display a Signature Pad on the iOS platform.

I used this tutorial for that: https://blog.xamarin.com/using-custom-uiviewcontrollers-in-xamarin-forms-on-ios/

This is how the code looks at the moment:

In the shared code

namespace PCL.CustomControls
{
public class SignaturePad:ContentPage
{
public SignaturePad()
{
BackgroundColor = Color.Red;
}
}
}

In the iOS platform specific project: (This works great)
[assembly: ExportRenderer(typeof(SignaturePad), typeof(SignaturePad_iOS))]
namespace PCL.iOS.CustomRenderer
{
public class SignaturePad_iOS:PageRenderer
{
public override void ViewDidLoad()
{
base.ViewDidLoad();
var signature = new SignaturePadView(View.Frame);
signature.StrokeColor = UIColor.Red;
signature.SignatureLineColor = UIColor.Black;
signature.BackgroundColor = UIColor.Yellow;
View.AddSubview(signature);

    }
}

}

For Android I am trying the following, unfortunately I cannot use OnCreate, so that has put me in trouble in Xamarin Forms in this scenario:
[assembly: ExportRenderer(typeof(SignaturePad), typeof(SignaturePad_Droid))]
namespace PCL.Droid.CustomRenderer
{
public class SignaturePad_Droid:PageRenderer
{
base.OnCreate (bundle);

var signature = new SignaturePadView (this) {
    LineWidth = 3f
};
AddContentView (signature,
    new ViewGroup.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));

}

}

Can someone help me with the Droid imp0lementation.

Thanks

transparent ListView without custom renderer?

$
0
0

Doing a POC for a customer and their designer has come up with a design with a graded background for the pages. Can I make controls transparent without a custom renderer?

I have a feeling the answer is no!

Getting error while adding web refrence in xamarin forms app

$
0
0

hi all,
I am developing an app using ASMX webservice in xamarin studio.. When i adding "Add Web Refrence", error occured like this,

The type or namespace name 'ExtensionDataObject' does not exist in the namespace 'System.Runtime.Serialization' (are you missing an assembly reference?)
what i have to do next.. Please help me guys..

I have a problem "aapt.exe & packaged_resources"

$
0
0

I have a problem with my xamarin project Android.
When i do build, I get a error in aapt.exe (I not have idea what it's) and my project tried find obj\Debug\android\bin\packaged_resources, but is not possible be found.
Please, someone can help me? Will be awesome

Picture : http://i65.tinypic.com/1zyh8oi.png
[Bing Translator]

ControlTemplate

$
0
0

Hello I'm Trying to Write a ControlTemplate but it is not apearing in the
Xamarin.Forms namespace of the Xamarin.Forms.Core.dll.
Do I need to import another dll?


Background Service

$
0
0

Hi, how TO use background Service? Do you has example?

Xaml resource style for custom controls

$
0
0

I have a custom control TextEntry which derives from Edit. I want to apply a style to it, however, the custom xaml namespace and TargetType aren't playing nice. Below is an excerpt which shows the style and different ways i've tried addressing the TargetType issue .

The Resource dictionary - excerpt

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:controls="clr-namespace:GRES.App.Forms.CustomControls;assembly=GRES.App.Forms"
             x:Class="GRES.App.Forms.CustomControls.GresPage">
  <ContentPage.Resources>
    <ResourceDictionary>
      <!--Entry Styles-->
      <Style x:Key="DefaultEntry" TargetType="{controls:TextEntry}">
      <!--styles-->
      </Style>
    </ResourceDictionary>
  </ContentPage.Resources>
</ContentPage>

Try one:
TargetType="{controls:TextEntry}"
Result:
System.ArgumentException: Object of type 'GRES.App.Forms.CustomControls.TextEntry' cannot be converted to type 'System.Type'.

Try two:
TargetType="{x:Type controls:TextEntry}"
Result:
System.InvalidOperationException: Sequence contains more than one matching element

Try three:
TargetType="controls:TextEntry"
Result:
System.InvalidOperationException: Sequence contains more than one matching element

initializecomponent error C# xamarin

$
0
0

I need help solving this problem, it happen every time and after i Start using VS to Code Xamarin, this error keeps getting my team crazy, if anyone know how to solve this, please help us. I've searched on the internet but no definitely answer.

thx

Xamarin.InAppBillling: No response from InAppBillingServiceConnection.Connect()

$
0
0

Hi

I'm trying to get in app billing to work for android (inside a Xamarin.Forms app) but somehow I don't get any response from the InAppBillingServiceConnection. I've followed the instructions on http://components.xamarin.com/gettingstarted/xamarin.inappbilling.

I've put all my code in the MainActivity class right now just to show you what I've got:

    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
    {
        InAppBillingServiceConnection _serviceConnection;

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

            GlobalHelper.MainActivity = this;

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());

            _serviceConnection = new InAppBillingServiceConnection (this, publicKey);
            _serviceConnection.OnConnected += HandleOnConnected;
            _serviceConnection.OnInAppBillingError += HandleOnInAppBillingError;
            _serviceConnection.OnDisconnected += HandleOnDisconnected;

            // Attempt to connect to the service
            _serviceConnection.Connect();
        }

        void HandleOnDisconnected ()
        {

        }

        void HandleOnConnected ()
        {

        }

        void HandleOnInAppBillingError (InAppBillingErrorType error, string message)
        {

        }
    }

I've binded to all events but none of them get fired. Any idea what I'm doing wrong here?

Thanks

Background Images

$
0
0

how can i set up a background image for all my pages on my Xamarin forms application using c

Viewing all 58056 articles
Browse latest View live


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