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

'System.Runtime.InteropServices.COMException' occuring in event handler

$
0
0

I am using Matrix XMPP for a chat application. Due to this, I had to create an Interface for the view model for the chat page. In the view model, there is an event handler for receiving messages from another user, and in this event handler I add the newly received message to an ObservableCollection, so that the message will show up in the ListView (through binding).

When sending a message it is working fine; When the user presses the enter button, the Entry_Completed event is fired, and calls the view models 'send message' method, which adds the newly sent message to the observable collection and updates the view.

But when receiving a message I get the System.Runtime.InteropServices.COMException error. It says that

Additional information: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))

I am not sure how to solve this issue, any help would be appreciated


iOS Build Failing - Xmarin.Forms Shared Code using FFImageLoading

$
0
0

I'm probably just missing something really simple here but... I have a shared code Xamarin.Forms project in which I am attempting to use FFImageLoading CachedImage. The Code compiles and runs fine for android, but when ever I try to do an iOS build I get the following error -

Error Failed to resolve assembly: 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

Warning Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.

Warning Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

If I remove all references to FFImageLoad the iOS target compiles and runs fine.

Thanks in advance ;-)

SwitchCell IsEnabled not available with binding

$
0
0

Hello there.

I'm having trouble controlling the IsEnabled of a Switchcell with binding through a ViewModel. I know from Xamarin's own site that IsEnabled is not a public property for Switchcell, and I have tried a few things but can't seem to get it to work. I can't seem to find any example of anybody doing it or using a vcustomcell to do it.

I have worked with making a CustomCell with ViewCell, where I implemented a label and a switch to present a Switchcell. But could not get it working. It would still not allow me to utilize IsEnable. I played a bit further and tried to edit (temporarely!) the definition of SwitchCell in Xamarin, and by adding the the line: public static readonly BindableProperty IsEnabledProperty; The binding of IsEnabled gets accessible. How come this is not standard?

Any one know of a way of making IsEnabled public, and bindable? I would prefer not to make it in XAML, since I need it several places, so a class inheriting from ViewCell (SwitchCell?) would be nice!

Control Device Orientation

$
0
0

Hi, I have created a view renderer in iOS to play mp4 videos. The only problem is when the device changes orientation the view goes completely white.

Here is the code:

`public class VideoViewRenderer : ViewRenderer
{

    protected override void OnElementChanged(ElementChangedEventArgs<View> e)
    {
        base.OnElementChanged(e);

        var customView = Element as VideoView;

            var viewController = UIApplication.SharedApplication.KeyWindow.RootViewController;

            while (viewController.PresentedViewController != null)
            {
                viewController = viewController.PresentedViewController;
            }

            var filename = customView.Uri;

            var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var filename2 = Path.Combine(documents, filename);

            var url = new NSUrl(filename2, false);

            var avp = new AVPlayer(url);
            var avpvc = new AVPlayerViewController();
            avpvc.Player = avp;
            avp.Play();

            viewController.PresentViewController(avpvc, animated: true, completionHandler: null);
    }
}`

Enabled XamlC - NullReference exceptions on some forms

$
0
0

I enabled XamlC on XF 2.3.4, and while my start page manages to open, subsequent pages just fail with a NullReferenceException. Without XamlC, everything is just fine. I neither have build warnings nor anything at runtime to work with. Any idea on how I can diagnose this? Currently testing on Android only...

---> System.NullReferenceException: Object reference not set to an instance of an object
at Ridr.Client.Views.UserRideDetailsPage.InitializeComponent ()

Also, this makes me somewhat nervous on how reliable this is. It appears that this alters the runtime behavior of my app, which apparently can lead to issues. Thoughts on this?

How to acces the current view UIViewController from an external service

$
0
0

I'm creating a Service in Xamarin.Forms that needs to open a new UI.

For Android I'm using:

        private Context _activity;
        _activity.StartActivity(_authenticator.GetUI(_activity));

For iOS I need to access the current view to use the method PresentViewController();
Is there an equivalent to the Context object for iOS?

Thank you

Xaml file Background color not displayed

$
0
0

Am creating XAML page background color enabled but not displayed
code as given below

<ContentPage.Content>

        </Slider>
    </ContentPage.Content>
</StackLayout>~~_

xamarin.forms dll 2.3.4 accordion not working in galaxy 7 device

$
0
0

Upgraded to xamarin.forms dll 2.3.4 and now accordion is not working.


Android IOnMapReadyCallback Forms 2.3.4

$
0
0

My custom renderer is no longer work with Xamarin Forms 2.3.4. The behavior I am seeing is that none of pins are being drawn on the map if I provide a method for the IOnMapReadyCallback method.

It appears as though the interface is explicitly implemented in the standard renderer (recently introduced). I need to be able to get a reference to the NativeMap once the IOnMapReadyCallback method has been invoked. Is there a way I can get a reference to the NativeMap via some event? Do I wait on the property changed for the SetType() call?

Null reference exception when using CanExecute with ContextActions on Android

$
0
0

I am hitting a bug that has previously been reported in bugzilla ( https://bugzilla.xamarin.com/show_bug.cgi?id=33413 ).

What is happening is that, on Android, a null reference exception is occurring in Xamarin.Forms.Platform.Android.CellAdapter.OnContextActionCommandCanExecuteChanged when using CanExecute with ContextActions.

I am wondering if Xamarin on Android is expecting a derived form of EventArgs when CanExecuteChanged is triggered?
Does anybody know for sure whether it copes with simply "new EventArgs()" or does it need an instance of a class derived from EventArgs? If so, does anybody know which one?

Xamarin forms PCL load image onto a WebView from PhotoLibrary

$
0
0

I will select the photos from photo library and save the paths of the images like

string ImagePath="/var/mobile/Containers/Data/Application/45CBAD31-B6F7-4636-8799-A7A3D01D42A6/Documents/temp/IMG_20170412_141910.jpg";

This is the selected image path on a Iphone.

Now while creating the pdf using Html i want to include this image into the pdf. For that i tried the following.

                var emailMessenger = CrossMessaging.Current.EmailMessenger;
                         if (emailMessenger.CanSendEmail)
                         {
                             var email = new EmailMessageBuilder()
                               .To("---@gmail.com")
                               .Cc("-----@hotmail.com")
                               .Bcc(new[] { "----@gmail.com", "----@gmail.com" })
                               .Subject("Xamarin Messaging Plugin")
                                .BodyAsHtml("<html>\n<head>\n<style>\ntable {\n    font-family: arial, sans-serif;\n    border-collapse: collapse;\n    width: 100%;\n}\n\ntd, th {\n    border: 1px solid #dddddd;\n    text-align: left;\n    padding: 8px;\n}\n\ntr:nth-child(even) {\n    background-color: #dddddd;\n}\n</style>\n</head>\n<body>\n\n<table>\n </table>\n\n</body>\n <img sr='/var/mobile/Containers/Data/Application/45CBAD31-B6F7-4636-8799-A7A3D01D42A6/Documents/temp/IMG_20170412_141910.jpg' alt='image'/> </html>") .Build();

 emailMessenger.SendEmail(email);

}

Is this the right way to load the selected image from photo gallery?

Picker Control Watermark Color/ Hint Color

$
0
0

Hi,

 I developed a project (Portable Library) in Xamarin studio for three platform iOS,android and Windows phone.That work fine in iOs and Android.

When running that project in Windows phone I am facing an issue.

The problem is i have used a picker control in project.And that has a placeholdertext. There is option for changing the placeholder text color in both iOS and Android. But couldn't find any solutions for changing the color in windows phone renderer.Please give a solution for changing the Placeholder text color in Windows Phone renderer class.

The Render Class in windows project I used is as below

    protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
    {
        base.OnElementChanged(e);

        if (Control != null && Element != null)
        {
            Control.Background = new SolidColorBrush(Colors.Transparent);

            Control.PlaceholderText = "Select";
            Control.BorderBrush = new SolidColorBrush(Colors.Transparent);
            Control.VerticalContentAlignment = VerticalAlignment.Center;
            Control.HorizontalContentAlignment = HorizontalAlignment.Left;
            Control.Foreground = new SolidColorBrush(Colors.Black);
            var element = Element as BurndyRegPicker;
            element.Title = string.Empty;?

            element.Margin = new Xamarin.Forms.Thickness(-10, -6, -28, 4);

            }
        }
    }

Thanks

Prasad CP.

Mob: +91 9496380738

How to display listview in two columns

$
0
0

I have seen this question answered, but the responses don't apply to the situation I'm trying to address.

I want to display two separate list items in each row of a ListView. What I don't want is to line up vertically the fields in each record one to a row.

My aim is to list two complete records in each row, one in each column. Each cell would include the image and accompanying text, which are separate fields in the record.

This is a crude representation:

| R0 | R1 |
| R2 | R3 |
| R4 | R5 |
and so on . . .

I've tried using separate binding contexts for each column as well as putting each row in a tuple. But so far I can't figure out how to match the data to the binding of the ListView.

I'd be grateful to hear from anyone who's solved this problem.

Thanks

Firebase Cloud Messaging iOS Configure() error.

$
0
0

I am working on adding Firebase Cloud Messaging to a Xamarin iOS project. I am using the following guide, https://components.xamarin.com/gettingstarted/firebaseioscloudmessaging. I started with a blank Xamarin forms project and began following the directions in the mentioned link.

I am getting an error when I add App.Configure (); to the FinishedLaunching method in my AppDelagate class. The error states that "app does not contain a definition for Configure ". Does anyone have any idea why I am getting this error? Is there a better guide to use for implementing FCM? Should the Configure function already be there or is that something that I need to create?

How to make a simple splashscreen?

$
0
0

I've been trying to create a simple splashscreen within a Xamarin Forms PCL project, which shows a single full image. The next view is my MainPage on Xamarin Forms, which has the same image with two buttons.
To properly fill the screen with the image without distort the image, I'm using an Image with AspectFill inside of a Relative Layout:

<Image
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}"
Aspect = "AspectFill"
Source = "splash"
VerticalOptions = "FillAndExpand"/>

The AspectFill does exactly what I need:
"Scale the image to fill the view. Some parts may be clipped in order to fill the view."

In my IOS project I just draw the same launch screen and the image matches the MainPage image. Unfortunately, it doesn't happen on Android.
I guess what I need is an Android layout that looks like my MainView, but I couldn't write this the same way as "AspectFill" does :(

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  <item>
    <bitmap
        android:src="@drawable/splashlogo"
        android:gravity="fill_vertical|fill_horizontal"/>
  </item>
</layer-list>

I know it's wrong because to fill the screen both vertical and horizontal distort the image, then it doesn't match the next image.
So, what happens is that my splashscreen on Android is distorted.
I've tried to use an ImageView instead of bitmap, like:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
    <RelativeLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:gravity="fill" android:layout_gravity="center">
        <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/splashlogo" android:scaleType="fitXY" />
    </RelativeLayout>
</LinearLayout>

But the only thing I see is a blank screen in the splashscreen and I don't know why.
Does anybody has a solution for this?


ProGuard: "java.exe" exited with code 1.

$
0
0

Hi everyone,

in my Xamarin.Forms project I added ModernHTTPClient library and now the ProGuard step breaks with error: "java.exe" exited with code 1.

The relevant log entries are attached.

I already increase the Java heap size to 1G and updated the ProGuard to latest version. I am also using Visual Studio 2017.

The ending portion of attached log file is below.

2> Note: there were 7 references to unknown classes. (TaskId:363)
2> You should check your configuration for typos. (TaskId:363)
2> (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass) (TaskId:363)
2> Note: there were 1 classes trying to access generic signatures using reflection. (TaskId:363)
2> You should consider keeping the signature attributes (TaskId:363)
2> (using '-keepattributes Signature'). (TaskId:363)
2> (http://proguard.sourceforge.net/manual/troubleshooting.html#attributes) (TaskId:363)
2> Note: there were 15 unkept descriptor classes in kept class members. (TaskId:363)
2> You should consider explicitly keeping the mentioned classes (TaskId:363)
2> (using '-keep'). (TaskId:363)
2> (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass) (TaskId:363)
2> Note: there were 9 unresolved dynamic references to classes or interfaces. (TaskId:363)
2> You should check if you need to specify additional program jars. (TaskId:363)
2> (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass) (TaskId:363)
2> Note: there were 3 accesses to class members by means of introspection. (TaskId:363)
2> You should consider explicitly keeping the mentioned class members (TaskId:363)
2> (using '-keep' or '-keepclassmembers'). (TaskId:363)
2> (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember) (TaskId:363)
2>PROGUARD : warning : there were 14 unresolved references to classes or interfaces.
2> You may need to add missing library jars or update their versions. (TaskId:363)
2> If your code works fine without the missing classes, you can suppress (TaskId:363)
2> the warnings with '-dontwarn' options. (TaskId:363)
2> (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) (TaskId:363)
2> java.io.IOException: Please correct the above warnings first. (TaskId:363)
2> at proguard.Initializer.execute(Initializer.java:473) (TaskId:363)
2> at proguard.ProGuard.initialize(ProGuard.java:233) (TaskId:363)
2> at proguard.ProGuard.execute(ProGuard.java:98) (TaskId:363)
2> at proguard.ProGuard.main(ProGuard.java:538) (TaskId:363)
2> Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 (TaskId:363)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2025,3): error MSB6006: "java.exe" exited with code 1.
2>Done executing task "Proguard" -- FAILED. (TaskId:363)
2>Done building target "_CompileToDalvikWithDx" in project "MyProjectXXX.Mobile.Android.csproj" -- FAILED.: (TargetId:310)
2>

There are also many messages in the log similar to the following.

2> Note: the configuration doesn't specify which class members to keep for class 'android.support.design.widget.Snackbar$Callback$DismissEvent' (TaskId:363)
2> Note: the configuration doesn't specify which class members to keep for class 'android.support.design.widget.Snackbar$Callback' (TaskId:363)
2> Note: the configuration doesn't specify which class members to keep for class 'android.support.design.widget.Snackbar$Duration' (TaskId:363)
2> Note: the configuration doesn't specify which class members to keep for class 'android.support.design.widget.CoordinatorLayout$Behavior' (TaskId:363)
2> Note: the configuration doesn't specify which class members to keep for class 'android.support.design.widget.CoordinatorLayout$DefaultBehavior' (TaskId:363)

Please let me know if you have any idea on how to solve this.

How to "refresh view" while loop or correctly write loop in async

$
0
0

Hi,
can anyone help me how to "refresh view" while application waiting for end of function or how to write this function in async (I read somewhere it could help)?
For example any easy function with loop:

private void CountAndWrite()
{
    for(int i = 0; i < 100000; i++)
    {
        Console.WriteLine(i.ToString());
        labelText.Text = i.ToString();
    }
}

Thank you.

No embeddedresources found for **Page** Exception

$
0
0

I always use to get this exception if i do any change in Xaml Page.
Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for Page at
Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject,System.Type).

And after rebuild the code works perfectly fine.Why i always need to rebuild every time? And this problem i am facing since i update the Xamarin-Forms to 1.3.

Xaml page are designed using Xamarin.forums but blank page is viewed how to solve this???

$
0
0

Am creating Xamarin.Forums XAML file are designed but run on android device black page are only displayed
code are given below
how to solve this????/

    <StackLayout HorizontalOptions="FillAndExpand">
        <StackLayout.BackgroundColor>
            <OnPlatform x:TypeArguments="Color"
                         Android="#51COD4"
                         iOS="51COD4"
                         WinPhone="51COD4"></OnPlatform>
        </StackLayout.BackgroundColor>
        <ContentPage.BackgroundColor>
            <Label Text="Welcome to Xamarin Forms!"
           VerticalOptions="Center"
           HorizontalOptions="Center" />
    <Slider VerticalOptions="FillAndExpand"></Slider>
        </ContentPage.BackgroundColor>

    </StackLayout>

Loop in the background?

$
0
0

Hello everyone
,
I have a problem with my xamarin forms project, I just passed it to a macbook and when I started it with the ios device it does not, it throws me an error making me reference that I did not find the resources of images and only to discard another error Add the images only background and I did it but now the image does not expand all over the screen, and is created as a kind of loop that the image is repeated several times
IOS

ANDROID

Viewing all 76418 articles
Browse latest View live


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