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

Best Practice for WIndows Apps Packaging

$
0
0

So the way Xamarin forms splits out the projects, it doesnt seem possible to "bundle" the apps into one package. Do you have to make 2 separate "Apps" in the Windows developer portal? E.g

MyApp for Windows Phone
MyApp for Windows 10

Or is it possible to have just MyApp and it include both packages? Thanks!


TabbedPaged and the "More" on iOS

$
0
0

Hi,

I am learning Xamarin Forms and have created an app successfully on Android with the TabbedPaged. I have multiple tabs and each one pulls up a different page that queries a local sqlite DB. I update the tab by the following event:

Current PageChanged += (sender, e)  => {
    App.MyManager.myService.set_query_settings(CurrentPage.Title);
}

And this worked on Android where each table had a title that represented the dynamic portion that was used to update the query to the sqlite for the specific column needed in the page.

Well, this gets a "System.NullReferenceException" in iOS when I select the "More" button and I would think it is because it pulls up that dialog list of my items to select. It works for the few items that are listed next to the "More" but not the "More" button itself.

My question is what do I do with this iOS specific problem? I haven't really delved into a CustomerRenderer but am guessing this is where I need to go. Is there someone that can point out a direction or links with examples on how to resolve this or something similar?

Thanks!

Bryant

Image image = new Image(); after this call, image is null??????

$
0
0

I don't get it. I break at the line right after this one:

Xamarin.Forms.Image image = new Xamarin.Forms.Image();

and image is null. I've actually restarted my computer and it still happens. Am I losing my mind?

[edit]
I was losing my mind. Seems the only way to use it is to go with documentation:
Image image = new Image { Source = someSource };

How to add image in navigation bar (Title bar) in xamarin.forms

$
0
0

Hi,

How to add image in navigation bar (Title bar) in xamarin.forms?

Debug Error

$
0
0

Hi,

When i update xamarin.Forms package from nuget and rebuid solution i getting below error.

Error 363 The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Void Android.Widget.AbsListView::SetSelectionFromTop(System.Int32,System.Int32)' (defined in 'Xamarin.Forms.Platform.Android, Version=1.3.2.0, Culture=neutral, PublicKeyToken=null') from 'Xamarin.Forms.Platform.Android, Version=1.3.2.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Widget.AbsListView::SetSelectionFromTop(System.Int32,System.Int32)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
--- End of inner exception stack trace ---
at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() Marcone.Android

Picker popup is shown twice when calling focus()

$
0
0

Hello

I've an issue when a Picker (in my example an ExtendedPicker, but it also happens with a normal Picker). In some cases (see below), when calling Picker's focus() method, the popup opens twice in Android simulator (not sure about iOS/real device).

In my case I've got a ListView with a Picker on each item. They work as long as I don't delete an item. After I deleted an item, on some still existing items when opening Picker, it's opened twice.

To reproduce the problem, you can load the project from here: https://github.com/skurth/App1

1) Start app
2) Delete group "Tübach City" by pressing "Delete" button next to it.
3) Press on one of the three "Kopf" buttons from group "PSW Tübach" (not from group "1. FC Schwangere Bergente", there still one popup opens correctly). They open a picker.
4) Press OK on the opened Picker.
5) Another picker popup is shown. Why?

Is there something I do wrong or is it a bug?
Relevant code is in file "ItemCell.cs", starting from line 39.

(The reason why I set picker IsVisble=false and using a button instead of the standard picker label is because I need to customize font etc., and this way it's easier than writing a custom renderer for Picker.)

button is not completely displayed Android portrait

$
0
0

Hi,

I created the group button by inheriting the Frame. this button is displaying good in Android Landscape mode and in Android portrait mode it displayed only half button? is there any suggestion to resolve this issue?

Migrating iOS classic projects fail to build with device. MT2002 Error, BindableProperty

$
0
0

I've been seeing this problem popping up in the forum: old projects built under the classic iOS packages work in the simulator, but fail to build for an actual device. Here is the error:

/iOS/MTOUCHTASK: Error MT2002: Failed to resolve "Xamarin.Forms.BindableProperty Xamarin.Forms.BindableProperty::Create(System.Linq.Expressions.Expression1<System.Func2<!!0,!!1>>,!!1,Xamarin.Forms.BindingMode,Xamarin.Forms.BindableProperty/ValidateValueDelegate1<!!1>,Xamarin.Forms.BindableProperty/BindingPropertyChangedDelegate1<!!1>,Xamarin.Forms.BindableProperty/BindingPropertyChangingDelegate1<!!1>,Xamarin.Forms.BindableProperty/CoerceValueDelegate1<!!1>)" reference from "Xamarin.Forms.Core, Version=1.2.3.0, Culture=neutral, PublicKeyToken=null" (MT2002) (Extracon.Survey.iOS)

Changing the linking to "Link All Assemblies"builds OK, but the you don't get touch events firing, so not a real solution.

I built using the -v -v -v -v option, with the attached log file. I believe that the problem (as pointed out in other posts) is that an old version of Xamarin.Forms is being linked based upon this log error (See "Xamarin.Forms.Core, Version=1.2.3.0, Culture=neutral, PublicKeyToken=null"):

MTOUCHTASK: error MT2002: Failed to resolve "Xamarin.Forms.BindableProperty Xamarin.Forms.BindableProperty::Create(System.Linq.Expressions.Expression1<System.Func2<!!0,!!1>>,!!1,Xamarin.Forms.BindingMode,Xamarin.Forms.BindableProperty/ValidateValueDelegate1<!!1>,Xamarin.Forms.BindableProperty/BindingPropertyChangedDelegate1<!!1>,Xamarin.Forms.BindableProperty/BindingPropertyChangingDelegate1<!!1>,Xamarin.Forms.BindableProperty/CoerceValueDelegate1<!!1>)" reference from "Xamarin.Forms.Core, Version=1.2.3.0, Culture=neutral, PublicKeyToken=null"
--- inner exception
Mono.Cecil.ResolutionException: Failed to resolve Xamarin.Forms.BindableProperty Xamarin.Forms.BindableProperty::Create(System.Linq.Expressions.Expression1<System.Func2<!!0,!!1>>,!!1,Xamarin.Forms.BindingMode,Xamarin.Forms.BindableProperty/ValidateValueDelegate1<!!1>,Xamarin.Forms.BindableProperty/BindingPropertyChangedDelegate1<!!1>,Xamarin.Forms.BindableProperty/BindingPropertyChangingDelegate1<!!1>,Xamarin.Forms.BindableProperty/CoerceValueDelegate1<!!1>)
at Mono.Linker.Steps.MarkStep.MarkMethod (Mono.Cecil.MethodReference reference) [0x00000] in :0
at Xamarin.Linker.Steps.MobileMarkStep.MarkMethod (Mono.Cecil.MethodReference reference) [0x00000] in :0
at MonoTouch.Tuner.MonoTouchMarkStep.MarkMethod (Mono.Cecil.MethodReference reference) [0x00000] in :0
at Mono.Linker.Steps.MarkStep.MarkInstruction (Mono.Cecil.Cil.Instruction instruction) [0x00000] in :0
at Xamarin.Linker.Steps.CoreMarkStep.MarkInstruction (Mono.Cecil.Cil.Instruction instruction) [0x00000] in :0
at MonoTouch.Tuner.MonoTouchMarkStep.MarkInstruction (Mono.Cecil.Cil.Instruction instruction) [0x00000] in :0
at Mono.Linker.Steps.MarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x00000] in :0
at MonoTouch.Tuner.MonoTouchMarkStep.MarkMethodBody (Mono.Cecil.Cil.MethodBody body) [0x00000] in :0
at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in :0
at Xamarin.Linker.Steps.CoreMarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00000] in :0
at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00000] in :0
at Mono.Linker.Steps.MarkStep.Process () [0x00000] in :0
at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in :0
at Xamarin.Linker.Steps.MobileMarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in :0
at Xamarin.Linker.Steps.CoreMarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in :0
at MonoTouch.Tuner.MonoTouchMarkStep.Process (Mono.Linker.LinkContext context) [0x00000] in :0
at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00000] in :0
at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List1& assemblies) [0x00000] in <filename unknown>:0 --- at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List1& assemblies) [0x00000] in :0
at MonoTouch.Target.LinkAssemblies (System.String main, System.Collections.Generic.List`1& assemblies, System.String output_dir, MonoTouch.Tuner.MonoTouchLinkContext& link_context) [0x00000] in :0
at MonoTouch.Target.ManagedLink () [0x00000] in :0
at MonoTouch.Target.ProcessAssemblies () [0x00000] in :0
at MonoTouch.Target.BuildApp () [0x00000] in :0
at MonoTouch.Application.BuildApp () [0x00000] in :0
at MonoTouch.Application.Build () [0x00000] in :0
at MTouch.Main2 (System.String[] args) [0x00000] in :0
at MTouch.Main (System.String[] args) [0x00000] in :0
Task "MTouchTask" execution -- FAILED

I have tried:
1) Cleaning All (Did not work)
2) Deleting and reinstalling Xamarin.Forms, Labs, whatever packages I think might might be outdated. iOS Xamarin.Forms is 1.4.2
Have NOT completely restarted the project b/c I have others and really don't want to screw up my repositories by restarting projects from scratch.

The must be a config file somewhere that is pointing the linker to the old Xamarin.Forms.Core - which are now gone - but I can't find where.

Any suggestions?

Shane


A sample project using Camera control (MediaPicker) of XLabs

$
0
0

Here is the link to .zip of a sample project for using Camera control of XLabs. It's named XPA_PickMedia_XLabs_XFP.

XPA stands for 'Cross Platform App' and XFP stands for 'Xamarin Forms PCL'. In my app I set links to the needed files in this project so that any changes in it are automatically taken account for.

I have tested this in Android (Galaxy Note 4) and Windows Phone (Lumia 830). I have not tested it in iOS 8 as I am yet to have a paid account and my iOS simulators are not loading apps. If someone can test it in iOS, I will be very thankful.

I have written some notes in the CameraViewModel.cs on how to use it.

Please let me know if you have any comments, concerns or improvements.

Xamarin.Forms WebView Does Not Work Once the Navigating EventHandler is Setup

$
0
0

I am working on a project that is using a Xamarin.Forms WebView to display HTML on a ContentView.
I want the user to be able to click the links in the HTML, then the app will ask the user if they want to go to their browser, and if so, do a Device.OpenUri(uri) to take the user there. Like so:

var webView = new WebView();

webView.Source = new HtmlWebViewSource
{
    Html = "<p>This is some html</p><a href='http://www.google.com'>Google</a>",
};

webView.Navigating += Helper.ConfirmNavigationAndSendToWebBrowserApp;

Then the event is handled by this method

public static class Helper
{
    public static async void ConfirmNavigationAndSendToWebBrowserApp(object sender, WebNavigatingEventArgs e)
    {
        var uri = new Uri(e.Url);
        e.Cancel = true; // prevent local browsing

        var webViewSender = (WebView)sender;

        if (e.Url.StartsWith("http"))
        {
            try
            {
                // Must stay on UI thread for iOS
                var response = await webViewSender.Navigation.NavigationStack.FirstOrDefault().DisplayAlert("Are you sure?",
                    "Are you sure you want to open this page in your web browser?", "Go to Browser", "Cancel")
                    .ConfigureAwait(continueOnCapturedContext: true);

                if (response)
                {
                    Device.OpenUri(uri);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }
    }
}

The WebView displays fine as long as the webView.Navigating EventHandler set up is commented, but once I uncomment it, the WebView will not display on the page. It seems like the WebView just does not work or is broken once the event handler is setup.

I have already read about allowing http web addresses on iOS in the Info.plist and I have added that to my project with the same result. I do not get this issue on Android, this code works fine on Android. I am working to create a custom render on iOS, but it looks like I might be having the same issue with Xamarin iOS UIWebView where is does not work once the LoadStarted EventHandler is setup.

Has anyone else experienced either the issue with Xamarin.Forms or Xamarin iOS? Does anyone have an idea for a solution?

I am working to get a demo project that would replicate the issue to post here.

How can I draw a signature in Xamarin.Forms?

$
0
0

Hi guys,

I am looking for a way to draw signatures from Xamarin.Forms. Is there any plugin which works fine with Xamarin.Forms 1.5?

I have tried with ACR SignaturePad Plugin but it does not work fine on iOS...

Sample applications for Xamarin Forms from Github not compiling or working with Visual Studio 2015

$
0
0

Hi,

Seeing the samples and the functionality is the best way to learn something new.

But trying to run the samples from this https://github.com/xamarin/xamarin-forms-samples none of them work compile properly or run without an issue on Android devices.

Can anyone from Xamarin do something to fix these issues and ensure that they run without issues on Visual Studio 2015 and the latest version of Xamarin Forms. It is a nightmare trying to find out certain features and how they work but unable to see the output on devices.

Please take this as a priority and ensure that the .Net developers are able to develop for Android with ease by studying these samples.

Thanks,

Rajesh.

how to set Rowheight value as dynamic in ListView

$
0
0

Hi,

I am using ListView in my Xamarin Forms app. I have set the Rowheight = "100" in XAML, is there any way to set this value as a dynamic?

Is it possible to use Facebook Account Kit with Xamarin.Forms?

How to make a Picker focusable on Android, but without the EditText being editable

$
0
0

To support keyboard usage on Android, I want my Pickers to be focusable, and want the user to be able to open the Picker and select an item, but do not want the EditText to be editable. Can anybody advise how to do this please.


Best setup for a speedy debug cycle, when developing with Xamarin Forms

$
0
0

What is the best target to use in terms of having a quick debug cycle. I.e. time to edit the code, run and test. I understand some platforms and emulators are slower than others, and whilst I am building a prototype I would like to use the quickest platform to do the most debugging/testing with.

For example if I am developing an application using Xamarin Forms to target (iOS, Android and Windows Phone), which target is the quickest prototyping, debugging and testing? Assuming that I would be using Visual Studio on Windows, and have a separate Mac for doing the iOS builds and testing.

Any thoughts and considerations greatly appreciated.

Is it possible to use a custom font for ToolbarItems?

$
0
0

I'm interested in using just text for the items in my toolbar. I am successfully seeing the text in the toolbar on top. Also, I have successfully loaded a custom font to be used on certain Buttons and Labels. I'm wondering if it's possible to use a custom font for the text button in the toolbar.

WebView and page load time

$
0
0

HI,

Is it possible to measure time required for web page (URL) to load in webview, with all underlaying content like pictures, ... ?

or is there any other strategy where natively (on iOS and Android) you could measure how long does it take for page to open ?

Thanx,
D

In iOS, Xamarin Forms WebView Navigating event called after assigning source

$
0
0

Hi All,

I have a WebView that has a binding for the Source and a Navigating event as below.

<WebView x:Name="htmlContent" HeightRequest="10000" WidthRequest="10000" 
                 IsVisible="{Binding HasLoaded}"
                 Source="{Binding Html}"
                 Navigating="WebViewNavigating"/>

In Android when i assign value to Html, the WebViewNavigating is not called, whereas in iOS, it is called multiple times. What is the reason for this behaviour.

I am trying to cancel further navigation after the webview is loaded and i'm doing that in WebViewNavigating

private void WebViewNavigating(object sender, WebNavigatingEventArgs e)
        {
            e.Cancel = _model.HasLoaded;
        }

But, in iOS, since it is being called multiple times, i am having some issues.

Question with ZXing and Xamarin Forms

$
0
0

I have done some extensive searching on this issue and finding very few support documents.

I am trying to take an already existing image download here```` with a simple barcode on it and process the barcode in a PCL layer of the project.

Here is the code i am processing:

private void ReadBarcode()
        {
            try
            {
                var imageBytes =imagingHelper.GetImage(ImagePath);
                var width = imagingHelper.GetWidth(ImagePath);
                var height = imagingHelper.GetHeight(ImagePath);
                LuminanceSource source = new ZXing.RGBLuminanceSource(imageBytes, (int)width, (int)height);
                HybridBinarizer hb = new HybridBinarizer(source);
                var a = hb.createBinarizer(source);
                BinaryBitmap bBitmap = new BinaryBitmap(a);
                BarcodeReader reader = new BarcodeReader();
                reader.Options.TryHarder = true;

                MultiFormatReader reader1 = new MultiFormatReader();
                try
                {
                    var r = reader1.decodeWithState(bBitmap);
                    var result = reader.Decode(source);
                    var result2 = reader.DecodeMultiple(source);
                    if (result != null)
                    {
                        return;
                    }
                    return;
                }
                catch (Exception ex)
                {
                    HandleError("ReadBarcode Error: ",ex.Message);
                }
            }
            catch (Exception ex)
            {
                HandleError("ReadBarcode Error: ", ex.Message);
            }
        }

for the image helper (at the android level)

public override uint GetWidth(string photoPath)
        {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.InPreferredConfig = Bitmap.Config.Argb8888;
            Bitmap bitmap = BitmapFactory.DecodeFile(photoPath, options);
            return bitmap.GetBitmapInfo().Width;
        }

        public override uint GetHeight(string photoPath)
        {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.InPreferredConfig = Bitmap.Config.Argb8888;
            Bitmap bitmap = BitmapFactory.DecodeFile(photoPath, options);
            return bitmap.GetBitmapInfo().Height;
        }
        public override byte[] GetImage(string photoPath)
        {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.InPreferredConfig = Bitmap.Config.Argb8888;
            Bitmap bitmap = BitmapFactory.DecodeFile(photoPath, options);

            var width = bitmap.GetBitmapInfo().Width;
            var height = bitmap.GetBitmapInfo().Height;
            int size = bitmap.RowBytes * (int)bitmap.GetBitmapInfo().Height;
            ByteBuffer byteBuffer = ByteBuffer.Allocate(size);
            bitmap.CopyPixelsToBuffer(byteBuffer);
            byte[] byteArray = new byte[byteBuffer.Remaining()];
            byteBuffer.Get(byteArray);
            return byteArray;
        }

Every single one of my results are turning up null and i'm unsure how to proceed. I have downloaded the latest beta package and on xamarin forms 2.1.0.6529

any help in this would be great i'm not sure if there is something wrong or what.

I should also note that even at the android level it appears to not return a result.

Viewing all 91519 articles
Browse latest View live