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

Writing test cases in Xamarin Forms


how to calculate Beep frequency in xamarin.forms IOS

$
0
0

I want calculate the Beep frequency in xamarin.forms ios

Accessing Web API with proxy settings in HttpClient throws Exception

$
0
0

Hi,
I have problem of requesting HTTPs service with using proxy setting. when I try to do proxy, the exception is thrown "One Or More Errors occurred " also i couldn't get any detailed error in stack trace..

I get this error when a client attempts to connect to our web services through a proxy. The proxy is set with Custom Web Proxy class mentioned in below Link.https://forums.xamarin.com/discussion/64550/proxy-authentication-in-xf-pcl


Sample Code:
**** Start of Http Client request service ****

        Uri uri = new Uri("Proxy Url : Port Number");
            HttpClientHandler handler1 = new HttpClientHandler()
            {
                Proxy = new WebProxy(uri),
                UseProxy = true
            };
            handler1.ClientCertificateOptions = ClientCertificateOption.Automatic;
            HttpClient httpClient1;
            if (handler1 != null)
                httpClient1 = new System.Net.Http.HttpClient(handler1);
            else
                httpClient1 = new System.Net.Http.HttpClient();
            httpClient1.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "application/json");
            httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Charset", "UTF-8");
            string url = BaseAddress + functionName + "?" + paramData;
            httpClient1.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", "");
            url = "Web api uri with function name";
            HttpResponseMessage response=httpClient1.GetAsync(new Uri(url)).Result;;

**** End of Http Client request service ****

Kindly advise on accessing web services when proxy enabled.

Kindly let me know is there any other approach needs to be taken to access through proxy.

I am using Xamarin.Forms 3.1 with .Net Framework 4.5

Visual Studio won't compile a IOS on my Mac

$
0
0

I had it working before I updated my PC and my Mac to the latest version of VS and Xamarin but now it says
Launch failed. The app 'ChowderApp.iOS' could not be launched on 'iPhone 6 Plus iOS 10.1'. Error: error MT0069: The app directory '/Users/ourweb1/Library/Caches/Xamarin/mtbs/builds/ChowderApp.iOS/a0ba67018c2b1c3f3eab418af7b01492/bin/iPhoneSimulator/Debug/net.ourweb.ChowderApp.app' does not exist.. Please check the logs for more details.
The app has been terminated.
How can I make the directory?

Getting the best performance for the least amount of work.

$
0
0

I have to say when I first began using XF, I was a little frustrated with the tooling and most importantly, the performance of XF. After a few months and getting to grips with the best ways to get the most from the platform, I’m really happy with the solution I completed. The only thing I wish was a little better is the performance on heavy traffic forms which seem to perform poorly.

I was rewriting a native IOS app and at first was surprised at the performance gap between forms and native. I had a view which contained a few hundred controls. In native this loaded almost immediately and in forms it was taking 10 seconds. I just can’t understand how the mapping between simple controls to a similar represntation on the target platform could differ so much in performance.

So I ended up doing a custom page renderer and doing the whole page natively, and the performance was much better. The only down side is then to having to then maintain multiple implentations. It crossed my mind that, maybe had I created custom renders for the individual controls rather than the whole page, how would that have compared? Obviously, that would reduce the code immensely and I’d be interested to hear any thoughts.

Does anyone know how to move the MainPage.xaml into a subfolder?

$
0
0

I am trying to migrate a Xamarin.Forms project that was originally created about 18 months ago to the latest Visual Studio and Xamarin.Forms 3.0. The old application had all of the views in a subfolder and they all derived from my own ViewBase class. I'd like to keep this architecture.

The problem is that the auto-generated MainPage.xaml.g.cs file now contains the wrong type.

Before, the auto-generated class looked like this:

    public partial class MainPage : global::Xamarin.Forms.ContentPage

Now it looks like this:

    public partial class MainPage : global::Xamarin.Forms.ViewBase

Which is plainly wrong because my custom base class is not defined in Xamarin.Forms.

Does anyone know how to fix this?

  • Patrick

Styling Xamarin Forms Droid Picker Popup window

$
0
0

I have a xamarin form android application and I cant see to figure out how to style the picker popup window. It looks as shown below. I want to remove the lines in between the items and change the colors of the cancel/ok buttons. I assume I need a custom renderer for this but when I attempt to do this it only stylelizs the picker itself, not the picker popup window. Any assistance is appreciated.

ObservableCollection and ListView Update

$
0
0

I have a scenario where i click a button to update quantity on the selected item in the listview. the update happends when i debug but does not update on the UI any help guys see attached.!


Xamarin Forms Map - Android Label Alignment on markers and info icon

$
0
0

I have a xamarin map and when a user clicks on the pins it shows the label address and title. In ios the label is left aligned and bold. However on Android the label in centered and bold. How can I make the label alignment in the marker left aligned.

In addition how can i get an info icon as shown in the screen shot below, from what I gather they are accessory views but how do I enable it?

why cant show pdf in pdf.js in UWP?

$
0
0

Hi.
I've been using pdf.js and a weibiew render to show a pdf or word file in UWP; in Release and Debug mode if it works, but when I generate the .appxbundle and install the application, I get a damaged Access error when trying to move the file from the local storage to the assets folder of the project.

The code to save the pdf:
// create file in public folder
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile sampleFile = await storageFolder.CreateFileAsync (filename, CreationCollisionOption.ReplaceExisting);

                // write sring to created file
                await FileIO.WriteBytesAsync (sampleFile, bytes);

                // get asets folder
                StorageFolder appInstalledFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
                StorageFolder assetsFolder = await appInstalledFolder.GetFolderAsync ("Assets");

                // move file from public folder to assets
                await sampleFile.MoveAsync (assetsFolder, filename, NameCollisionOption.ReplaceExisting);
                str = sampleFile.Name;

The code for the webview route:
Control.Navigate (new Uri (string.Format ("ms-appx-web: ///Assets/pdfjs/web/viewer.html? File = {0}", string.Format ("ms-appx-web: / // Assets / {0} ", WebUtility.UrlEncode (customWebView.Uri)))));

As I mentioned before, the pdf is seen in release mode and in debugu mode, but when I install the package application it marks me the error of 'access denied'; In the capabilities of my application I have everything that has to do with storage installed in my app. I would like to know how to solve this error.

Getting error: actool exited with code 255

$
0
0

I am getting the following exception when trying to build my Xamarin.Forms iOS project...
Target _CoreCompileImageAssets: Tool /Applications/Xcode.app/Contents/Developer/usr/bin/actool execution started with arguments: --errors --warnings --notices --output-format xml1 --output-partial-info-plist "/Volumes/MacBook Pro Backup/Xamarin/NSE/iOS/obj/iPhoneSimulator/Debug/device-builds/iphone7.1-11.3/actool/partial-info.plist" --app-icon AppIcons --launch-image LaunchImage --compress-pngs --filter-for-device-model iPhone7,1 --target-device iphone --minimum-deployment-target 7.1 --platform iphonesimulator --compile "/Volumes/MacBook Pro Backup/Xamarin/NSE/iOS/obj/iPhoneSimulator/Debug/device-builds/iphone7.1-11.3/actool/bundle" "/Volumes/MacBook Pro Backup/Xamarin/NSE/iOS/obj/iPhoneSimulator/Debug/device-builds/iphone7.1-11.3/actool/cloned-assets/Resources/Images.xcassets" /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error : actool exited with code 255 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: The "ACTool" task failed unexpectedly. /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: System.ArgumentException: Failed to parse PList data type: ---> System.ArgumentException: Must specify valid information for parsing in the string. /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at System.Enum+EnumResult.SetFailure (System.Enum+ParseFailureKind failure, System.String failureMessageID, System.Object failureMessageFormatArgument) [0x00024] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/enum.cs:318 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at System.Enum.TryParseEnum (System.Type enumType, System.String value, System.Boolean ignoreCase, System.Enum+EnumResult& parseResult) [0x00077] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/enum.cs:396 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at System.Enum.Parse (System.Type enumType, System.String value, System.Boolean ignoreCase) [0x00010] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/enum.cs:370 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at System.Enum.Parse (System.Type enumType, System.String value) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/enum.cs:362 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.PropertyListFormat+XmlFormat+Context.ReadObjectHead () [0x00018] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: --- End of inner exception stack trace --- /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.PropertyListFormat+XmlFormat+Context.ReadObjectHead () [0x00048] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.PropertyListFormat+XmlFormat+Context..ctor (System.Xml.XmlReader reader) [0x0000f] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.PropertyListFormat+XmlFormat.StartReading (System.IO.Stream input) [0x0008a] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.PropertyListFormat.CreateReadContext (System.IO.Stream input) [0x00010] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.PObject.FromFile (System.String fileName, System.Boolean& isBinary) [0x00024] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.PDictionary.FromFile (System.String fileName, System.Boolean& isBinary) [0x00001] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.PDictionary.FromFile (System.String fileName) [0x00001] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.Tasks.XcodeCompilerToolTask.Compile (Microsoft.Build.Framework.ITaskItem[] items, System.String output, Microsoft.Build.Framework.ITaskItem manifest) [0x002d0] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Xamarin.MacDev.Tasks.ACToolTaskBase.Execute () [0x009ba] in <35965be2bb8347aa861de1a3bb9a5f2b>:0 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:631 /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(1211,3): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder+<ExecuteInstantiatedTask>d__26.MoveNext () [0x00212] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:787 Done building target "_CoreCompileImageAssets" in project "NSE.iOS.csproj" -- FAILED.

Weird error when I compile : IBTool exited with code 255

$
0
0

Hi,

using Visual studio comunity version 7.4.1, on Macos high sierra 10.13.3
I got on github a sample of RSS reader : https: // github.com/Mahabali/XamarinRSSFeed

when I compile, at first : I can run it.

the IOS project target IOS 10.0
the droid project target latest android 8.1

then, all package needed to be updated.
si I updated all package,
and now, I have 2 errors, which (for me) are not telling me what is wrong :
IBTool exited with code 255
the "IBTool" task failed unexpectedly

I tried to delete all bin and obj, and I tried to clean ll before build, without success.

what can I do ?
except delete visual studio, nuget packages, and reinstall everything ? (this is not an option for me :o)

thanks
Olivier

does scrolled in scrollView accept a command??

$
0
0

I want to detect if the user is scrolling I've tried this

DetectScrollPosition is a command but it's not accepted? is there any other method??

AirWatch SDK Integration and incompatible packages

$
0
0

Hi,
I'm trying to add the AirWatch SDK into my XF android application. Soon I add the reference to dependent (AWFrameworkBindings.dll) or add Nuget package (AWSDK) into the project, I cannot compile the project and get the following errors

Attribute "fontStyle" already defined with incompatible format (values.xml)
No resource found that matches the given name: attr 'preferenceTheme' (values.xml)
Original attribute defined here (values.xml)

The dependencies specified in the AirWatch documentation (https://docs.vmware.com/en/VMware-AirWatch/9.3/vmware-airwatch-guides-93/GUID-AW93-SDK_Plugin_Xamarin.html) uses the version (25.3.1) for following however I have already used the latest version (26.1.01) for them in my project which I cannot downgrade I believe.

Xamarin.Android.Support.v13 version 25.3.1
Xamarin.Android.Support.v7.AppCompat version 25.3.1
Xamarin.Android.Support.v7.CardView version 25.3.1
Xamarin.Android.Support.v7.RecyclerView version 25.3.1
Xamarin.Android.Support.Design version 25.3.1
Xamarin.Android.Support.v14.Preference version 25.3.1
Xamarin.GooglePlayServices.SafetyNet version 32.961.0
Square.OkHttp3 version 3.5.0

Anybody experience the same issue and any solution to this.
Thanks in advance

Can someone explain me what is Binding And MVVM?

$
0
0

I’m starting in Xamarin.Forms and XAML, But there is almost nothing of information, I have an idea of what Binding Is, Correct me if I’m wrong, with binding I can, for example, have a variable called Name with the Value John inside, and if I put a label text =“{Binding Name}”, the label text should be John?, like a normal variable?, it’s the only I understand. Also if you have a good site where I can learn XAML, can you share it with me? Thanks.


Keep User Logged in on device

$
0
0

Hi,

I have made an app that has a Login Screen and the user enters their email and password that are checked against a an Azure table for validity. I want to keep the user logged in on their device, either Android or iOS so they do not have to log in everytime they run the app.

How can I achieve this plesae?

Force Token Refresh in Xamarin Forms Android, Cloud Messaging

$
0
0

I am trying to force a token refresh with Firebase. Sometimes it works and deleting the FirebaseInstanceId does trigger the OnTokenRefresh() but most of the times it doesn't and i don't understand why. I have to run the program a lot of times for the OnTokenRefresh to be triggered. When I put a break point on FirebaseInstanceId.Instance.DeleteInstnaceId() and then click Continue from the Debugger once that line is hit, the OnTokenRefresh() is not called.Google Play services availability method does return true, I checked. Any help please? Here is my code:

protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            //added for spalsh
            //base.Window.RequestFeature(WindowFeatures.ActionBar);
            //base.SetTheme(Resource.Style.MainTheme);

            base.OnCreate(bundle);

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

            //add for using maps
            Xamarin.FormsMaps.Init(this, bundle);

            //add for using with Azure
            CurrentPlatform.Init();

            //add for using local database
            string dbName = "sa_db.sqlite";
            string dbFolderPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            string dbFullPath = Path.Combine(dbFolderPath, dbName);

            //loadApplcation with db path ---> add dbFullPath as param
            LoadApplication(new App());

            // check if google play services are available
            var availability = IsPlayServiceAvailable();

#if DEBUG
            // Force the refresh of the token. If we deploy the app, no new token will be sent out
            Task.Run(() =>
            {
                //string currentToken = FirebaseInstanceId.Instance.Token;

                //This may not be executed on the main thread
                FirebaseInstanceId.Instance.DeleteInstanceId();             
                Console.WriteLine("Forced token: " + FirebaseInstanceId.Instance.Token);
            });
#endif
        }

In debug mode this should be triggered (but seems to only trigger on a random basis):

// should be triggered when InstanceId is deleted
 [Service]
        [IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
        public class MyFirebaseIIDService: FirebaseInstanceIdService
        {
            public override void OnTokenRefresh()
            {
                //base.OnTokenRefresh();

                var refreshedToken = FirebaseInstanceId.Instance.Token;
                // Token received message
                Console.WriteLine ($"Token received: {refreshedToken} ");

                SendRegistrationToServer(refreshedToken);
            }

    // check if GoogPlay Serice is available
    public  bool IsPlayServiceAvailable()
            {
                int resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(this);

                if (resultCode != ConnectionResult.Success)
                {
                    if (GoogleApiAvailability.Instance.IsUserResolvableError(resultCode))
                    {
                        // give the user a change to fix the issue
                        // error message
                    }
                    else
                    {
                        // play services not supported message

                        Finish();
                    }
                    return false;
                }
                else
                {
                    // services are available message               
                    return true;
                }
            }

Opening a PDF in a WinRT app

$
0
0

Hi,

I'm currently trying to open/read a pdf that is locally in my App local storage. (LocalState for WinRT)

I've been using this guide : https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/controls/display-pdf/

But it only shows how to open PDF that are packaged with the app. How can i open the pdf that i downloaded ?

I suspect there is a modification of URL in the Renderer but after many tries i can't get it to work.

I'm trying something like this :

Control.Source = new Uri(string.Format("ms-appx-web:///Assets/pdfjs/web/viewer.html?file={0}", string.Format("ms-appdata:///{0}", WebUtility.UrlEncode(path))));

But it only shows an empty reader.

Thanks a lot if you can provide me some infos on how to solve that problem

Error when compile a binding jar

$
0
0

My project is make in xamarin forms but the problem is when have to integrated with SDK nativo (android & iOS)(Why is very dificult use a SDK with Xamarin Forms?). I try the project binding jar, i add jar but when compile de binding project, i get error:

Error CS1721: Class 'DetectIDSchemaDB.PushInboxSchema' cannot have multiple base classes: 'Object' and 'BaseColumnsConsts' (CS1721) (EnlaceDetectId)

Error CS0507: 'ArrayWheelAdapter.GetItemTextFormatted(int)': cannot change access modifiers when overriding 'protected' inherited member 'AbstractWheelTextAdapter.GetItemTextFormatted(int)' (CS0507) (EnlaceDetectId)

Error CS0534: 'NumericWheelAdapter' does not implement inherited abstract member 'AbstractWheelTextAdapter.GetItemTextFormatted(int)' (CS0534) (EnlaceDetectId)

Sorry for my english, i speak spanish.

Thanks.

Correct place to store things securely

$
0
0

I'm doing some work with azure mobile services which requires me to store both an application key, and also cache user authentication information locally (not passwords, just a token).

Is there a standard approach to storing / caching something like this with Xamarin Forms?

Viewing all 77050 articles
Browse latest View live


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