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

Picking a Photo from the Picture Library


Contribution Attempt Failure

$
0
0

Hi,
I have tried to participate in fixing bugs but I have already spent 4 days trying to build the Xamarin.Forms successfully and I barely succeeded.
And still I have piles of questions.
I surfed the net for some document to guide me through setting up the project and understand the flow but resources were very limited and expired. One of them was talking about Bugzilla which apparently the Xamarin development team has dumped long time ago.
I think 4 days of each excited developer is a lot to waste. And I am sure a lot of people would give up on contributing by then.
Suggestions:
1- I strongly suggest to create a special Forum for Xamarin Contributors
2- Provide clear and up to date steps to open Xamarin project successfully. Like:
2-a- List required Nuget package sources should be specified
2-b- List required Visual Studio settings should be specified
2-c- List required Android sdk and settings should be specified.
2-d- List errors that do not go away but you still can work with their existence should be noted.
3- Tutorials should be created

A forum is really important and necessary.
I am sure if the above is available , you are going to get thousands of contributors

Xamarin Form IAP error the application is not configured for billing through Google Play

$
0
0

I am receiving the above error [0:] Error: Plugin.InAppBilling.Abstractions.InAppBillingPurchaseException: Unable to process purchase.

I am using Plugin.InAppBilling library.
My code looks like this.
public async Task PurchaseItem(string productId, string payload)
{
var billing = CrossInAppBilling.Current;
try
{
var connected = await billing.ConnectAsync(ItemType.InAppPurchase);
if (!connected)
{
//we are offline or can't connect, don't try to purchase
return false;
}

                //check purchases
                var purchase = await billing.PurchaseAsync(productId, ItemType.InAppPurchase, payload);

                //possibility that a null came through.
                if (purchase == null)
                {
                    Console.WriteLine("Purchase canceled!");
                }
                else if (purchase.State == PurchaseState.Purchased)
                {
                    var id = purchase.Id;
                    var token = purchase.PurchaseToken;
                    var state = purchase.State;
                    return true;
                }
            }
            catch (InAppBillingPurchaseException purchaseEx)
            {
                //Billing Exception handle this based on the type
                Debug.WriteLine("Error: " + purchaseEx);
            }
            catch (Exception ex)
            {
                //Something else has gone wrong, log it
                Debug.WriteLine("Issue connecting: " + ex);
            }
            finally
            {
                await billing.DisconnectAsync();
            }
            return false;
        }

For info all the below are checked

AndroidManifest must include "com.android.vending.BILLING" permission.
APK is built in release mode.
APK is signed with the release certificate(s). (Important: with "App Signing by Google Play" it only works if you download directly from GooglePlayStore!)
APK is uploaded to alpha/beta distribution channel (previously - as a draft) to the developer console at least once. (takes some time ~2h-24h).
IAB products are published and their status set to active.
Test account(s) is added in developer console.
My testing app is the same that is currently published in the Play Store

Binding iOS protocol

$
0
0

Hi,

one should think that I understood Bindings by now, but whenever it comes to iOS I face new adventures.

I created an objective-c framework that contains just one single class which has a header and main file.
This file defines a protocol in its header.

#import <Foundation/Foundation.h>
@protocol MyDelegate <NSObject>
    @required
    -(void) method1:(NSInteger *)value;
    -(void) method2:(NSString*) value;
    -(void) method3:(NSString*) value;
@end
@interface MyClass : NSObject
    +(void)addDelegate:(id <MyDelegate>)delegate;
@end

Then I want to only bind the delegate, I don't care for the MyClass (for the moment).
So what I defined is

[Protocol, Model]
[BaseType(typeof(NSObject))]
interface MyDelegate
{
    [Abstract]
    [Export("method1:")]
    public void Method1(int value);

    [Abstract]
    [Export("method2:")]
    public void  Method(string value);

    [Abstract]
    [Export("method3:")]
    public void Method3(string value);
}

If I build the binding project all is fine. If I build the iOS project that integrates the binding, all is fine.
However the MyDelegate class simply doesn't appear in the iOS project. It is not existent.

If I remove the [Protocol,Model] from the top of the definition I get an error telling me the class MyDelegate couldn't be found.
But I can confirm 100% that the framework contains the corresponding header file.

What am I doing wrong here?

Thank you!

How to Track Screen View for Xaml pages of Xamarin Forms using Google Firebase

$
0
0

Hello,

I am developing xamarin forms application and I want to track screen views for xaml pages in Xamarin Forms.
Is there any implementation for this?

Automatically increase the build number in xamarin forms app

$
0
0

Any one know how to automatically increase the build number in Android and IOS projects (whenever i do the release build)?

Note:
I am developing Xamarin forms app .

Regards
Thabo

Impossible to create APK

$
0
0

I'm trying to create an Archive APK for my application which works perfectly in Android emulator and compile without problems.
After a few seconds of work I get the message:
Archive process doesn't work. For details check Errors section.
But in Error section I just find this message:
It was not possible to create archive app 'Timesheet'. Android archive not valid (no file APK)

Does anybody know how to solve this situation?
It's a project I was working on before summer and I could create my archive then, but now it's not working and I really don't know what changed in the while.

Thanks
Michele

iOS 9.3.x fails at startup with VS Xamarin Forms 8.3.1

$
0
0

iOS 10.0 and above all work like before, but with the latest Xamarin Forms update I get at startup:

2019.10.01-13.01.44.790 (1) at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) <0xe1d70 + 0x0008c> in <e9fc9f9aa3924b8ab178e9f9b7538a42#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x2f0185 + 0x0008c> in <e9fc9f9aa3924b8ab178e9f9b7538a42#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x2f0293 + 0x00016> in <e9fc9f9aa3924b8ab178e9f9b7538a42#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) <0x2e573f + 0x00018> in <e9fc9f9aa3924b8ab178e9f9b7538a42#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at ObjCRuntime.Runtime.ConstructNSObject[T] (System.IntPtr ptr, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution) <0xcd477f + 0x00094> in <1b20576ce73640d782f136af13e79af3#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at ObjCRuntime.Runtime.GetNSObject[T] (System.IntPtr ptr) <0xcd5021 + 0x00152> in <1b20576ce73640d782f136af13e79af3#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at UIKit.UIKeyCommand.Create (Foundation.NSString keyCommandInput, UIKit.UIKeyModifierFlags modifierFlags, ObjCRuntime.Selector action) <0xd06c33 + 0x0006c> in <1b20576ce73640d782f136af13e79af3#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement]..ctor () <0xe9ddcf + 0x000cc> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) <0xe992bd + 0x0004c> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) <0xe9d62b + 0x00088> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () <0xe9d389 + 0x0007c> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () <0xebb34d + 0x001a2> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at (wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSendSuper(intptr,intptr)
at UIKit.UIViewController.get_View () <0xd01407 + 0x00038> in <1b20576ce73640d782f136af13e79af3#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) <0xebae57 + 0x0008a> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) <0xe992bd + 0x00062> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.Platform.AddChild (Xamarin.Forms.VisualElement view) <0xe99697 + 0x0008c> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.Platform.WillAppear () <0xe995e3 + 0x00068> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at Xamarin.Forms.Platform.iOS.PlatformRenderer.ViewWillAppear (System.Boolean animated) <0xe9b89b + 0x00028> in <732a941d6de945589075e4414a7b1b52#f5fca6ff644d4563e93b7f9f2a3883ef>:0
at (wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSend(intptr,intptr)
at UIKit.UIWindow.MakeKeyAndVisible () <0xd0194b + 0x00032> in <1b20576ce73640d782f136af13e79af3#f5fca6ff644d4563e93b7f9f2a3883ef>:0

Any ideas?


Xamarin Forms - Android 8.0

$
0
0

Just had to upgrade an older Xamarin Forms app to support Firebase messaging. In that process i needed to update some libraries

i ended up updating Xam Forms and didnt realize it was for 8.1 and 8.1 is not available on some phones that are still in use for that app (Samsung S7 for ex)

is there any way to use Xamarin Forms with Android 8.0 instead of 8.1?

thanks

How to get current ViewCell in ListView in OnItemAppearing

$
0
0

I am trying to fade in the cells for a ListView, but in order to do that I need to access the current cell being shown in OnItemAppearing. Anyone know how to do this?

Deep link not working when my app in closed

$
0
0

Hi,
I'm currently developing an app using Xamarin.forms. I want when user clicks on url inside text message, Open the app and go to specific page.
So, when the app is in background or opened all thing is Okay but when the app is closed, error message like "MyApp has stopped" appears!
please help me.
thanks.

FCM Push Notification documentation outdated

$
0
0

Hello everyone, i'm trying to implement Push Notifications in a Xamarin.Forms Project which wouldn't be a hassle if the documentation wouldn't be outdated and all the functions deprecated. After long search i couldn't find any examples for how to implement it with the most recent Version. Is there any other resource except the source itself?

Inline C# inside XAML Tapped or Clicked

$
0
0

Hi,

Is it possible to have an inLine C# code inside XAML's Tapped or Clicked?

Foe example something like this:

Tapped="{ Navigation.PopAsync(); }"

Thanks,
Jassim

Why does Xamarin HybridWebview not fill the screen on Android?

$
0
0

Hello everyone,
I am new to Xamarin and I am currently building an application which features a Xamarin Forms HybridWebView, just the one introduced on the official docs. (Cannot post links yet)
So far so good, everything works perfectly, but the HybridWebView does not occupy all of the screen space available... As seen here (I blurred out the content), there is a white bar underneath, it is not coming from the Page, since I defined a background-color and if I add Margins/Paddings I can see the color. So the Webview does not get rendered properly?

Here is my Layout:

<?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:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:controls="clr-namespace:Project.Controls"
             mc:Ignorable="d"
             x:Class="Project.CustomWebViewPage"
             NavigationPage.HasNavigationBar="False"
             NavigationPage.HasBackButton="False"
             BackgroundColor="#313131"
             Padding="0">
    <ContentPage.Content>
        <StackLayout>
            <controls:HybridWebView 
            x:Name="hybridWebView" 
            BackgroundColor="#313131"
            Margin="0"
            />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

and here, I initialize it:

            var hybridWebView = new Controls.HybridWebView
            {
                Uri = App.GLOBAL_URL,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            Padding = new Thickness(0, 0, 0, 0);
            Content = hybridWebView;

I have already tried:

  • Using Relative Layout
  • Using Absolute Layout
  • Setting Margin and Padding everywhere to 0
  • Using a Grid

Any help is very welcome, since I'm stuck with this for days..

Click button after some time

$
0
0

Hi,

I have set landing page as Mainpage and after some time span want to navigate to Login page.

Tried Task.Delay();


Dynamic styles

$
0
0

Hello,
In my application I created a class which makes ui responsive based on Width height and dpi of the device. Currently I use binding to a lot of xaml element's width and height. I have a problem with slow loading therefore I would like to change this aproach. Responsivnes works 100% its just slow.

My question is: Is it possible to generate .css file which would take width heigh dpi at the startup and calculate new values. Then use this Css and avoid using bindings.

Example:

// this is static
body{
width:300px;
height:200px;
}

// this is dynamic
// widthModifier=0,5;
// heightModifier=0,3;
body{
width:300 * widthModifier; //150px
height:200 * heightModifier; //60px
}

If not .css then maybe xaml styles.

Have anybody tried to do this before?

Custom Control BindableProperty propertyChanged not Firing

$
0
0

Trying to set up a very simple custom control to handle alignment when using bullet points in a label. The issue is, the Spans passed into the custom control are not being recognized and the content isn't getting rendered (and the propertyChanged function isn't firing). What am I missing?

XAML:

<?xml version="1.0" encoding="UTF-8" ?>
<ContentView
    x:Class="Sample.Controls.BulletPointItem"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:d="http://xamarin.com/schemas/2014/forms/design"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <ContentView.Content>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="10" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Label x:Name="BulletPoint" Text="&#x2022;" />
            <Label x:Name="LabelContent" Grid.Column="1" />
        </Grid>
    </ContentView.Content>
</ContentView>

Code-behind:

[ContentProperty(nameof(Spans))]
public partial class BulletPointItem : ContentView
{
    // todo add bindable props for bullet point size and color, or even which character to use as the bullet point!
    public static readonly BindableProperty SpansProperty =
        BindableProperty.Create(
            nameof(Spans),
            typeof(ObservableCollection<Span>),
            typeof(BulletPointItem),
            new ObservableCollection<Span>(),
            BindingMode.OneWay,
            propertyChanged: OnSpansChanged);

    public BulletPointItem()
    {
        InitializeComponent();
    }

    public ObservableCollection<Span> Spans
    {
        get => (ObservableCollection<Span>)GetValue(SpansProperty);
        set => SetValue(SpansProperty, value);
    }

    private static void OnSpansChanged(BindableObject bindable, object oldValue, object newValue)
    {
        var control = (BulletPointItem)bindable;
        var newSpansValue = (ObservableCollection<Span>)newValue;
        var formattedString = new FormattedString();

        if (control == null)
            return;

        if (newSpansValue == null || newSpansValue.Count == 0)
        {
            control.LabelContent.FormattedText = formattedString;
            return;
        }

        foreach (var span in newSpansValue)
        {
            formattedString.Spans.Add(span);
        }

        control.LabelContent.FormattedText = formattedString;
    }
}

Attempted Usage:

                            <controls:BulletPointItem>
                                <Span Text="Span 1." />
                                <Span FontAttributes="Italic" Text="Span 2." />
                            </controls:BulletPointItem>

iOS page covers status bar

$
0
0

What should I do to prevent the application cover the status bar area?
It covers the whole window and status icons are visible through top_grid on iPad 2 simulator


<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                       x:Class="test_cs_mobile_xamarin.main_page">
   <StackLayout>
      <Frame x:Name="top_frame" HasShadow="true" OutlineColor="Green" Padding="5,5,5,5" VerticalOptions = "FillAndExpand">
         <ScrollView  x:Name="top_scroll_view" VerticalOptions = "FillAndExpand">
            <Grid x:Name="top_grid" VerticalOptions = "FillAndExpand">
               <Grid.Children>
               </Grid.Children>
            </Grid>
         </ScrollView>
      </Frame>
      <Frame x:Name="bottom_frame" HasShadow="true" OutlineColor="Green" Padding="5,5,5,5" VerticalOptions = "FillAndExpand">
         <ScrollView x:Name="bottom_scroll_view" VerticalOptions = "FillAndExpand">
            <Label  Text="..." XAlign="Start" YAlign="Start" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" x:Name="bottom_label" LineBreakMode="WordWrap" />
         </ScrollView>
      </Frame>
      <StackLayout x:Name="bottom_stack_layout" Orientation="Horizontal">
         <Button Text="Add 1" x:Name="button_1"></Button>
         <Button Text="Add 2" x:Name="button_2"></Button>
         <Button Text="http" x:Name="button_3"></Button>
         <Button Text="http 1" x:Name="button_4"></Button>
      </StackLayout>
   </StackLayout>

How do I rotate a image with a gesture recognizer? Why do they have swipe, pinch and such, but not r

$
0
0

How can I rotate an image with a gesture recognizer? With one finger. Do I have to use a pan recognizer?

Xam.Plugin.Media Incompatibility with Camera Samsung Galaxy Tab A

$
0
0

Hi community,

Current, my friend of QA has reported a bug in my application with the camera.

So, when any user goes to take a photo, when that did take, that camera do to that my app back to the main page, but in other device this Nuget its correct and functional successful and i can continued with my navigation.

Any developer from this community has that this problem too?

this result is equals with the Nuget Plugin.FilePicker when I need that my user search one file or image, this device back to my main page.
:neutral:

this error i don't understand if is my code or its internal error with this device and mistake outside of me.

Device: Galaxy Tab A (2017)
Model: SM-T380
Android version: 9.0
One UI: 1.1
Builder: 180610.011.T380DXS3CSI2
Knox: 3.3 API level 28 TIMA 3.3.0

Viewing all 89864 articles
Browse latest View live


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