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

Foundation.MonoTouchException has been thrown in xamarin.forms

$
0
0

Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Application windows are expected to have a root view controller at the end of application launch..

I am using Prism Structure with xamarin.forms.My app is runing on android properly.when i run my app on ios then exception is occur..
i cleaned the whole project and after build all project but still error is coming..if any one has any solution then please suggest me..


I want to show a video player in eachcell in Listview in XAMARIN forms. Please suggest me.

$
0
0

Please let me know. Guys, I need some sort of suggestion.

My app command bar changed its color for no good reason

$
0
0

A strange thing happened to my application. The main window command bar (the one with minimize and maximize buttons) from common gray became black. The buttons stayed gray. I don't think I did anything to cause this.
Could you please give me any idea what did this and how to change this back?

Issue creating APK in VS 2017

$
0
0

Hi,
My Xamarin.Forms app works in debug mode, but if I build in release mode and I try to create an APK from VS 2017, it doesn't work.
The build process succeeded but the APK is not yet created.
My Xamarin.Forms version is 3.4.0.1008975 and my VS is up to date.

Target Android version is 9.0.

Here above the application logs:

Xamarin.VisualStudio.Publishing.ArchiveManager|Error|0|System.NotSupportedException: This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread.
at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.ObjectModel.ObservableCollection1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at Microsoft.VisualStudio.PlatformUI.HierarchyItem.HierarchyItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection1.Add(T item) at Microsoft.VisualStudio.PlatformUI.HierarchyItem.AppendChildren(IVsHierarchy hierarchy, UInt32 itemID, List1 appendedChildren)
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.FillChildren()
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.get_InternalChildren()
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.get_Children()
at Clide.SolutionExplorerNode.get_Nodes() in E:\A_work\184\s\src\Clide\Solution\SolutionExplorerNode.cs:line 166
at Clide.ITreeNodeExtensions.<>c.b__1_0(ISolutionExplorerNode x) in E:\A_work\184\s\src\Clide.Interfaces\Extensions\ITreeNodeExtensions.cs:line 33
at Traverser.d__21.MoveNext() in E:\A\_work\184\s\src\Clide.Interfaces\Extensions\Traverser.cs:line 70 at System.Linq.Enumerable.<OfTypeIterator>d__951.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Clide.AndroidClideExtensions.GetAndroidResources(IProjectNode projectNode) in E:\A_work\293\s\src\Core\VisualStudio.Android\ProjectSystem\Extensions.cs:line 128
at Xamarin.VisualStudio.Android.Publishing.AndroidArchiveToolsService.CreateParameters(IProjectNode project) in E:\A_work\293\s\src\Core\VisualStudio.Android\Services\Publishing\Archival\AndroidArchiveToolsService.cs:line 186
at Xamarin.VisualStudio.Android.Publishing.AndroidArchiveToolsService.ArchiveAsync(IProjectNode project, IProgressReport progress, CancellationToken cancellationToken) in E:\A_work\293\s\src\Core\VisualStudio.Android\Services\Publishing\Archival\AndroidArchiveToolsService.cs:line 113
at Xamarin.VisualStudio.Publishing.ArchivableProjectBase.d__8.MoveNext() in E:\A_work\293\s\src\Core\VisualStudio.Publishing\Archival\ArchivableProjectBase.cs:line 30
--- End of stack trace from previous location where exception was thrown ---

Read pixel data of Image in Xamarin Forms

$
0
0

Hi Team,
I am looking to get help on converting Image to 3D byte array, reading its RGB values
This code works fine on my .Net platform, but with Xamarin I have trouble getting Color and Bitmap class working together. Could someone help me get an equivalent code for Xamarin platform ?

    byte[] imageData = new WebClient().DownloadData(imurl);
                MemoryStream imgStream = new MemoryStream(imageData);
                curr_img = Image.FromStream(imgStream);
                Bitmap bmp = new Bitmap(curr_img);

                int wSize = curr_img.Width;
                int hSize = curr_img.Height;

                image_inlist = new List<List<List<int>>>(); 
                for(int i=0; i < hSize; i++)
                {
                    List<List<int>> eachrow = new List<List<int>>();
                    for(int j=0; j<wSize; j++)
                    {
                        Color clr = bmp.GetPixel(j, i);
                        eachrow.Add(new List<int> {clr.R,clr.G,clr.B});

                    }
                    image_inlist.Add(eachrow);
                }

UWP app breaks when the code execution comes to displayalert line

$
0
0

I am using displayalert in my project and it is working fine on android and ios devices. But for the UWP part it is not working in some pages. When the code execution comes to displayalert line the UWP app breaks and redirecting to App.g.i.cs. Code control comes to the following if block.

#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
        UnhandledException += (sender, e) =>
        {
            if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
        };
#endif

If I mouse over the e showing {Windows.UI.Xaml.UnhandledExceptionEventArgs}

I am using the following code for display alert:

await DisplayAlert("Alert", "A verification code has been sent to your email.", "OK");

If I changed the above lines like below, no issue will come.

Device.BeginInvokeOnMainThread(async () => 
{
    await DisplayAlert("Alert", "A verification code has been sent to your email.", "OK");
});

Is there any solution to this issue without adding Device.BeginInvokeOnMainThread? And what is the reason behind this issue?

Bottom navigation in all the screens

$
0
0

Hi
I have 4 items in bottom navigation ,so i want these Bottom navigation in all the screens.For example even if i click on Hmaburger menu items the bottom navigation should be there..How to do this..please help

Thanks

VS 2017 xamarin sample - Hello, Android Multiscreen: Quickstart.

$
0
0

I am attempting to create the first Xamarin form. Using the sample HELLO, ANDROID MULTISSCREEN; QUICKSTART. I am at ADDING A LIST. Instruction Next, create an empty list that can be filled with phone numbers. The MainActivity class will look like this.
[Activity(Label = "Phoneword", MainLauncher = true)]
public class MainActivity : Activity
{
static readonly List phoneNumbers = new List();
...// OnCreate, etc.
}

Their is a copy sign but, there is not instruction as where to copy and place this code. All other code have instruction as where to paste the code. Please help.


How to use Google Drive in Xamarin Forms?

$
0
0

Hi!
1. As the title, How to use Google Drive in Xamarin Forms?
I have found this link but it use CustomRenderer.

  1. How many way to use Google Drive in Xamarin Formns?
  2. How to use it directly in PCL (NET Standard)?

Thank you!

Xamarin Forms Listview Example

$
0
0

I am fairly new to xamarin and I am trying to create a list view, using xamarin forms and mvvmcross.
I am trying to follow a tutorial I found online, I can't give the link yet.
This gave an error because he, set the binding context to his viewmodel.
But my viewmodel has parameters, I used a prebuilt template, and I can't pass them from the page code.

His code:

public partial class CarsPage : ContentPage {

    public CarsPage() {

        InitializeComponent();

        // Connecting context of this page to the our View Model class
        BindingContext = new CarsViewModel(); // it crashes on this line in my code.
    }

}

My viewmodel code:

    private MvxObservableCollection<VoorwerpItem> voorwerpen;
    public MvxObservableCollection<VoorwerpItem> Voorwerpen
    {
        get { return Voorwerpen; }
        set
        {
            Voorwerpen = value;
        }
    }


    public MainViewModel(IMvxNavigationService navigationService, IMvxLogProvider mvxLogProvider, Services.IAppSettings settings, IUserDialogs userDialogs)
    {
        this.navigationService = navigationService;
        this.mvxLogProvider = mvxLogProvider;
        this.settings = settings;
        this.userDialogs = userDialogs;

        this.log = mvxLogProvider.GetLogFor(GetType());

        Voorwerpen = new MvxObservableCollection<VoorwerpItem>()
        {
             new VoorwerpItem() { Name = "Fiets E", Type = "fiets" }
        };

    }

I have search a lot online trying to find a example of a listview with forms and mvvmcross that works.
However I have been unsuccesfull so far.
How can I have a listview with mvvmcross?
Any example or derication is much appreciated.
I am sorry for not being able to give an better question.

Persisting data locally (Device cache)

$
0
0

Hi,

Is there a way how you can persist some trivial data locally, such as personId or cartvalue so that when the app is switched off, the value can be retrieved again?

I have been playing around with Application.Current.Properties ["ProfileId"] but the value is lost once the application is closed.

Thanks
Shaun

How to make a multi-steps registration page with multi ContentView?

$
0
0

In the app I'm working on, there's a multi-steps registration, 4 steps:
to accomplish it, I'm thinking to have a single page to host a content view of the registration step, when it passes the validation requirements I remove it and inject the next content view.

This is an example to simplify my need:

<?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:local="clr-namespace:XamApp"
             x:Class="XamApp.MainPage">

    <StackLayout>
        <local:Register1/>
    </StackLayout>
</ContentPage>

and the Register1 looks like this:

    <ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:local="clr-namespace:XamApp"
                 x:Class="XamApp.Register1">
        <ContentView.Resources>
            <ResourceDictionary>
                <local:IntToBoolConverter x:Key="intToBool"/>
            </ResourceDictionary>
        </ContentView.Resources>
        <ContentView.Content>
            <StackLayout>
                <Label Text="Page 1" FontSize="Large"/>
                <Entry x:Name="txtName" Placeholder="Name"/>
                <Button Text="Next" IsEnabled="{Binding Source={x:Reference txtName},
                                        Path=Text.Length,
                                        Converter={StaticResource intToBool}}"
                        Clicked="Button_Clicked"/>
            </StackLayout>
        </ContentView.Content>
    </ContentView>

There are two problems:

1- I don't know how to handle the data (view model) between steps, to have only one object through all steps (Shall I use DI? if yes , then how in MVVMLight?)
2- How to to inject the content view into the main registration page dynamically in an MVVM fashion ?

Generate token from credit card Stripe.Net

$
0
0

Since Stripe.Net doesn't work anymore in the PCL side, we need to use DependencyServices<>. However, when I'm trying to generate a token from credit card information, it seems like... It's missing in the doc, I just can't find anything on the web or in the doc, is that normal?

I would like to achieve something like that :

public string CardToToken()
{
    var card = new Card()
    {
        Number = "4242424242424242",
        ExpiryMonth = 12,
        ExpiryYear = 16,
        CVC = 123
    };

    try
    {
        token = await Stripe.CreateToken(card);
    }
    catch (Exception ex)
    { 
        return null;
    }

    return token;
}

So then I can just simply send it to my server. Any idea to achieve something that easy? That's the last point I need to finish for my project...

This example is in my Android side.

Thank for any help...

Learning Resources for MVVMLight with Xamarin.Forms?

$
0
0

I'm looking for good resources and documentation for using MVVMLight with Xamaring.Forms, but I'm struggling, there're few of them and they don't fill the gab and the official web site seems outdated. We are already using it in our projects, but there's a mess in the code due to the lack of knowledge of how to use MVVMLight and its locator and IoC container. I'm thinking to migrate to MVVM Cross because it has a very nice documentation. but I don't want to take this step before knowing more about the library we already using and I think it's powerful and suit our needs.
any help?

Unable to build any Xamarin.Forms app

$
0
0

For a few days I cannot build anymore. Even a new empty Forms project (the one that displays « Welcome to Xamarin.Forms! ») displays the LaunchScreen.storyboard tab and 3 error messages:

ibtoold[8369:648873] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[SimServiceContext serviceContextForDeveloperDir:error:]: unrecognized selector sent to class 0x11396dc00'

It looks like this has begun after Xcode 10.0 was installed on my Mac (High Sierra 10.13.6, no pending update in the AppStore). I use Visual Studio Community 7.6.6 (build 17), no pending update in the stable channel. I cannot work anymore.

Any idea how to progress?


Button text inside a Grouped Listview header is not binding to group property.

$
0
0

Hi I am trying to dynamically changed the button text inside Groupheader in GroupListview but its always empty. Below is the code snippet.

                      <Button  Grid.Row="0" Grid.Column="3" Text="{Binding **ButonText**}" WidthRequest="175" 
                                      BackgroundColor="White" 
                                      Command="{Binding AddImages}" 
                                      CommandParameter="{Binding Source={x:Reference Item}, Path=BindingContext}"
                                      BindingContext="{Binding Source={x:Reference GroupedView},Path=BindingContext}"      />  

But when i remove the binding Context from Button than Text is displayed properly but than Command does not work.

Thanks in Advance.

Is there any nuget for Rounded Entry Borders in Xamarin Forms ?

$
0
0

I tried all the tutorials with custom renderer and I always have errors like constructor is version 2.5 etc ... Is there any other way to do rounded entry borders ?

How to get rid of Hamburger icon

$
0
0

I have been revisiting one of my old Xamarin apps and I noticed the hamburger icon appear on the bottom navigation bar.

Does anyone know how to get rid of this?

Xamarin.Forms iOS Build Failure

$
0
0

Have a Xamarin.Forms project with net standard 2 XF assembly driving UWP and iOS apps. Running XF v3.4.0.1008975 on Visual Studio Community 2017 15.9.4 on the latest Windows 10. Mac that is performing the build is running Mojave 10.14.1 and Visual Studio Mac 7.7.2 (Build 21).

UWP application builds and runs with no problems. iOS build was running without any problems up to about two weeks ago.

Now the iOS build throws out several MT0136 warnings for assemblies that are referenced by the net standard assembly and then crashes out with MT2001 that tells me that encountered an error while processing references of the net standard 2 assembly. This is after the detection of the signing identity output and the linker setting is do not link (debug mode).

Any guidance is greatly appreciated. Note that I already tried common approaches involving deleting bin/obj directories and mac build cache cleanup.

Which version of NDK should we use? not latest?

$
0
0

I was told that we should always use the version NDK according to below
https://github.com/xamarin/xamarin-android/blob/master/build-tools/android-toolchain/android-toolchain.projitems

as it seems 14b version is used, we can use highest 14b? which is from march 2017, pretty old. why is it? I tried used 18b today latest version and my project works fine in debug mode and compiles also fine in release mode. Problem occurs when i want to install the app in release more or try to create a package. I get this exception

Error       XA5101: C compiler for target Arm was not found. Tried paths: 
"C:\Android\android-ndk-r18b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-gcc.exe; 
C:\Android\android-ndk-r18b\prebuilt\windows-x86_64\bin\gcc"

So, can someone confirm from xamarin team if we can rely on android-toolchain.projitems file or we can simply use latest NDK, maybe my exception is something else?

Viewing all 91519 articles
Browse latest View live


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