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

App resuming results in crash with FormsAppCompatActivity

$
0
0

I have a Xamarin Forms app, currently being built for Android. I have a MainActivity that used to extend FormsApplicationActivity, but because I want to use a custom theme I had to change it to extend FormsAppCompatActivity (see my other question: http://stackoverflow.com/questions/35754590/xamarin-forms-custom-theme-not-working).

Ever since changing from FormsApplicationActivity to FormsAppCompatActivity the app crashes whenever I switch out of the app and then back into the app. It throws an error in the App.xaml.cs class in the OnResume method, where I try to set the MainPage to a new navigation page:

protected override void OnResume()
{
    bool isRegistered = _authenticationService.IsRegistered();

    MainPage = isRegistered 
        ? new NavigationPage(new LoginPage()) 
        : new NavigationPage(new RegisterPage()); // this results in the crash
}

The error I'm getting is:

Java.Lang.IllegalStateException: Can not perform this action after
onSaveInstanceState

This is the stacktrace:

03-09 13:43:52.098 I/MonoDroid( 1243): Java.Lang.IllegalStateException: Can not perform this action after onSaveInstanceState
03-09 13:43:52.098 I/MonoDroid( 1243):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Android.Runtime.JNIEnv.CallIntMethod (IntPtr jobject, IntPtr jmethod) [0x00063] in /Users/builder/data/lanes/2098/3efa14c4/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:386 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Android.Support.V4.App.FragmentTransactionInvoker.Commit () [0x00033] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.SwitchContentAsync (Xamarin.Forms.Page view, Boolean animated, Boolean removed, Boolean popToRoot) [0x000e1] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnPushAsync (Xamarin.Forms.Page view, Boolean animated) [0x00000] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.PushViewAsync (Xamarin.Forms.Page page, Boolean animated) [0x00000] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.<OnElementChanged>b__13_0 (Xamarin.Forms.Page p) [0x00000] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.EnumerableExtensions.ForEach[T] (IEnumerable`1 enumeration, System.Action`1 action) [0x00010] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1 e) [0x001af] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (Xamarin.Forms.Platform.Android.TElement element) [0x000fc] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001f] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement view) [0x00000] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.AddChild (Xamarin.Forms.Page page, Boolean layout) [0x00015] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x00090] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage (Xamarin.Forms.Page page) [0x0001a] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.AppOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x0001e] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Application.set_MainPage (Xamarin.Forms.Page value) [0x0008b] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Smartbit.App.OnResume () [0x00020] in C:\Users\leonc\Documents\Visual Studio 2015\Projects\Smartbit\Smartbit\Smartbit\App.xaml.cs:52 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Application.SendResume () [0x00006] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnStateChanged () [0x00039] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnRestart () [0x00019] in <filename unknown>:0 
03-09 13:43:52.098 I/MonoDroid( 1243):   at Android.App.Activity.n_OnRestart (IntPtr jnienv, IntPtr native__this) [0x00009] in /Users/builder/data/lanes/2098/3efa14c4/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:4539 
03-09 13:43:52.098 I/MonoDroid( 1243):   at (wrapper dynamic-method) System.Object:cba7a870-1435-4f70-9059-e10915aba0c0 (intptr,intptr)
03-09 13:43:52.098 I/MonoDroid( 1243):   --- End of managed exception stack trace ---
03-09 13:43:52.098 I/MonoDroid( 1243): java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1448)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1466)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:613)
03-09 13:43:52.098 I/MonoDroid( 1243):  at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.n_onRestart(Native Method)
03-09 13:43:52.098 I/MonoDroid( 1243):  at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.onRestart(FormsAppCompatActivity.java:86)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.app.Instrumentation.callActivityOnRestart(Instrumentation.java:1181)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.app.Activity.performRestart(Activity.java:5291)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.app.Activity.performResume(Activity.java:5302)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2764)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2803)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.os.Handler.dispatchMessage(Handler.java:102)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.os.Looper.loop(Looper.java:136)
03-09 13:43:52.098 I/MonoDroid( 1243):  at android.app.ActivityThread.main(ActivityThread.java:5001)
03-09 13:43:52.098 I/MonoDroid( 1243):  at java.lang.reflect.Method.invokeNative(Native Method)
03-09 13:43:52.098 I/MonoDroid( 1243):  at java.lang.reflect.Method.invoke(Method.java:515)
03-09 13:43:52.098 I/MonoDroid( 1243):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
03-09 13:43:52.098 I/MonoDroid( 1243):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
03-09 13:43:52.098 I/MonoDroid( 1243):  at dalvik.system.NativeStart.main(Native Method)

Attribute "imageaspectratioadjust" Already Defined with Incompatible Format

$
0
0

For a day, I am facing problem when I try to build my Droid project and the above error arises. This happened after I updated my plugins and Xamarin Forms to 2.5.x.xxxx. I have made sure all projects have same Xamarin Forms version but nothing has changed. Any help from other developers? I understand I am not the first one facing the issue.
Complete error:
Severity Code Description Project File Line Suppression State
Error {Project.Path}XXXX.Droid\obj\Debug\lp\78\jl\res\values\values.xml:1: error: Attribute "imageAspectRatioAdjust" already defined with incompatible format

Future of Xamarin.Forms: Rendering in HTML5 and Compiling into JavaScript?

$
0
0

Hello Community,

This has been on my mind with the new year, and I just wanted to get it out there and get some discussion around it.

Currently, the vision around Xamarin.Forms is around building native UIs from a single code base. With the amazing talent of Jason Smith and team (and also of the community!), I don't think there will be any problem reaching all the target platforms in great fashion and functionality. In fact, I believe there are already community efforts around WPF and WinRT renderers for Xamarin.Forms.

The problem I have been thinking about is this: let's say I am a start-up (and I am. :)), and I am going to build an app. I would use Xamarin.Forms to reach all the target app stores. Now, my problem is... what happens when a user loads my website on their device/workstation? Websites (or web applications) are obviously rendered in HTML5/JavaScript these days. This is something that Xamarin.Forms (as awesome as it is) does not do, currently (as far as I know). And so, I have been wondering if this is a known issue, and (more importantly) a known/possible direction for Xamarin.Forms.

Ideally, we (my start-up) would have 1 single code base (as currently designed/possible with Xamarin.Forms) that has rendering projects for:

  • iOS (possible today)
  • Droid (possible today)
  • Windows Phone (possible today)
  • Windows Store (or "Universal Apps" -- not entirely possible just yet, but again as mentioned WinRT rendering is a community effort)
  • Web Application (not possible today, but would render in HTML5/JavaScript)

Then I, as a start-up, would only need 1 developer to hit all these primary target platforms. Otherwise, I would have to hire 1 Xamarin developer and 1 web application/site developer (and incur the overhead of two code bases -- precisely the problem space that Xamarin aims to solve).

As I am sure you know, a good (perfect, actually) example of a web application is Facebook. They have developed all of their native applications for the native app stores, but if you visit Facebook.com in your phone's browser, you will see a HTML5 application that does pretty much everything the native applications do (or in Windows Phone's case, even better. :P )

Has there been discussion around this? I would love to know, and sincerely apologize if there is and I am just adding to the noise.

Thank you for any discussion/feedback you can provide around this matter,
Michael

ListView NullReferenceException when reseting / updating ItemSource

$
0
0

In my ViewModel I have a property called 'Objects' which is an ObservableCollection.

When I setup the ListView it is as such:

ObjectList = new ListView()
{
        IsPullToRefreshEnabled = true,
        HasUnevenRows = ViewModel.HasUnevenRows,
        RefreshCommand = ViewModel.LoadObjects,
        ItemsSource = ViewModel.Objects,
        ItemTemplate = new DataTemplate(ViewModel.ListViewItem),
        BindingContext = ViewModel
};
ObjectList.SetBinding(ListView.IsRefreshingProperty, new Binding("IsLoading"));

My ViewModel has an IsLoading property and I am making sure I'm not reloading the list while it is already being loaded via the command CanExecute:

LoadObjects = new Command(() => { ListObjects(); },() => { return !IsLoading; });

When I pull to refresh it executes the LoadObjects command.

The issue I am encountering is when I pull to refresh the list, after the 3rd or 4th time it will crash with this:

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Forms.Platform.iOS.LabelRenderer.UpdateText () [0x00070] in <8f7e3b9d1483403590c8ab3d78cce1ac>:0 
  at Xamarin.Forms.Platform.iOS.LabelRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00097] in <8f7e3b9d1483403590c8ab3d78cce1ac>:0 
  at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:137 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\agent\_work\3\s\Xamarin.Forms.Core\Element.cs:388 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x000f4] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:593 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:390 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindingExpression.cs:174 
  at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) [0x0006b] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindingExpression.cs:77 
  at Xamarin.Forms.Binding.Apply (System.Object newContext, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty) [0x00042] in C:\agent\_work\3\s\Xamarin.Forms.Core\Binding.cs:126 
  at Xamarin.Forms.BindableObject.ApplyBindings (System.Boolean skipBindingContext) [0x0003b] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:421 
  at Xamarin.Forms.BindableObject.ApplyBindings () [0x00000] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:125 
  at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x0005a] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:119 
  at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in C:\agent\_work\3\s\Xamarin.Forms.Core\Element.cs:498 
  at Xamarin.Forms.Element.OnBindingContextChanged () [0x00021] in C:\agent\_work\3\s\Xamarin.Forms.Core\Element.cs:341 
  at Xamarin.Forms.View.OnBindingContextChanged () [0x00042] in C:\agent\_work\3\s\Xamarin.Forms.Core\View.cs:99 
  at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x00060] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:120 
  at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in C:\agent\_work\3\s\Xamarin.Forms.Core\Element.cs:498 
  at Xamarin.Forms.Element.OnBindingContextChanged () [0x00021] in C:\agent\_work\3\s\Xamarin.Forms.Core\Element.cs:341 
  at Xamarin.Forms.View.OnBindingContextChanged () [0x00042] in C:\agent\_work\3\s\Xamarin.Forms.Core\View.cs:99 
  at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x00060] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:120 
  at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in C:\agent\_work\3\s\Xamarin.Forms.Core\Element.cs:498 
  at Xamarin.Forms.Element.OnBindingContextChanged () [0x00021] in C:\agent\_work\3\s\Xamarin.Forms.Core\Element.cs:341 
  at Xamarin.Forms.Cell.OnBindingContextChanged () [0x00000] in C:\agent\_work\3\s\Xamarin.Forms.Core\Cells\Cell.cs:114 
  at Xamarin.Forms.BindableObject.BindingContextPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x0000e] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:441 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00108] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:596 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:390 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0005f] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:543 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:83 
  at Xamarin.Forms.BindableObject.set_BindingContext (System.Object value) [0x00000] in C:\agent\_work\3\s\Xamarin.Forms.Core\BindableObject.cs:24 
  at Xamarin.Forms.Internals.TemplatedItemsList`2+<UnhookItem>d__154[TView,TItem].MoveNext () [0x000b0] in C:\agent\_work\3\s\Xamarin.Forms.Core\TemplatedItemsList.cs:1217 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/src/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 
  at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/src/UIKit/UIKitSynchronizationContext.cs:24 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/src/Foundation/NSAction.cs:163 
--- End of stack trace from previous location where exception was thrown ---
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at HydrusCRM.iOS.Application.Main (System.String[] args) [0x00001] in /Volumes/Data/Apps/HydrusCRM/iOS/Main.cs:17 

Here is the code that updates the objects collection:

var result = (IList)JsonConvert.DeserializeObject(results, listType);
if (result.Count > 0)
{
    Device.BeginInvokeOnMainThread(() =>
    {
        foreach (Models.Objects.Model @object in result)
        {
        objects.Add(@object);
    }
    });
}

I am not sure where the issue is coming from as none of my apps code is in the exception stack.

Capturing and viewing traffic from iPhone device

$
0
0

I've got a xamarin forms app that is calling a webservice. For some reason the webservice is returning errors and I want to check the request that my app is making.

through the simulator it all works OK but something on the device isn't working correctly.

I've got Fiddler running on a Windows box, set it to allow remote connections and set a proxy on my iPhone WiFi connection. Got a bit of strange scenario:

Fiddler is able to capture the traffic from Safari and other apps on the phone
I've got some analytics installed and the calls to the analytics web service are being picked up
The calls to my App WebService are not being picked up in Fiddler.

Not sure what is going on, any ideas? or other suggestions on how I can view check? im not using HTTPS and the messages are reaching my webservice as i have seen it being hit in the logs.

ListView not binding in Prism 7

$
0
0

Below I am showing my xaml file with a ListView control and my ViewModel... I am trying to binding some items to the ListView, but nothing happens.

I am using Prism 7 as my MVVM framework.

This is my xaml with a listview:

            <ListView x:Name="lancamentos" ItemsSource="{Binding LancamentosCollection}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                <Label Text="{Binding Descricao}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"></Label>
                                <Label Text="{Binding Data}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"></Label>
                                <Label Text="{Binding Valor}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"></Label>
                                <Label Text="{Binding Tipo}" HorizontalOptions="StartAndExpand" VerticalOptions="Center"></Label>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

This is my ViewModel:

public class ClosedIncomePageViewModel : ViewModelBase
{
    private LancamentosFatura _lancamentosFatura;
    private Fatura _fatura;

//HERE IS MY COLLECTION USED AS A SOURCE IN MY LISTVIEW. IT IS PUBLIC, CAUSE IT IS AN ESSENCIAL CONFIGURATION !!!
    public ObservableCollection<Lancamento> LancamentosCollection { get; set; }

    public Fatura Fatura
    {
        get { return _fatura; }
        set { SetProperty(ref _fatura, value); }
    }

    public LancamentosFatura LancamentosFatura
    {
        get { return _lancamentosFatura; }
        set { SetProperty(ref _lancamentosFatura, value); }
    }

    public ClosedIncomePageViewModel(INavigationService navigationService)
        : base(navigationService)
    {
        LancamentosFatura = new LancamentosFatura();
    }

    public override void OnNavigatedTo(NavigationParameters parameters)
    {
        if (parameters.ContainsKey("lancamentos_fatura"))
        {
            LancamentosFatura = (LancamentosFatura)parameters["lancamentos_fatura"];

            //Atribui apenas o segundo elemento da lista de faturas (equivalente a primeira fatura fechada)
            LancamentosFatura.FaturaVisualizada = LancamentosFatura.Faturas[1];

            //Obtem os lançamentos e carrega Listview
            ObterLancamentos();
        }
    }

    private async void ObterLancamentos()
    {
        try
        {
            //Carrega o Loading...
            using (UserDialogs.Instance.Loading("Carregando..."))
            {
                await Task.Run(() => ProcessarXML());
            }

            if (LancamentosFatura.Lancamentos != null)
            {
                if (LancamentosFatura.Status.Codigo == "0")
                {

        //HERE I AM BINDING THE LIST<LANCAMENTO> TO MY LISTVIEW
        //THE LancamentosFatura.Lancamentos IS COMING WITH ITEMS, BUT THE LISTVIEW IS NOT BINDING THE ROWS
                    LancamentosCollection = new ObservableCollection<Lancamento>(LancamentosFatura.Lancamentos);

                    Toast("Lançamentos da fatura fechada recuperadas com sucesso", System.Drawing.Color.Green);
                }
                else
                {
                    Toast("Não foi possível recuperar os lançamentos da fatura fechada", System.Drawing.Color.Red);
                }
            }
            else
            {
                Toast("Não foram encontrados lançamentos para a fatura fechada", System.Drawing.Color.Orange);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    private void ProcessarXML()
    {
    ...
    }
}

Here is my Lancamento class:

public class Lancamento : ModelBase
{
    public Lancamento(XmlElement element)
    {
        Data = GetTextValue(element, "dt_lancto");
        Descricao = GetTextValue(element, "desc_lancto");
        Valor = GetTextValue(element, "vl_lancto");
        Tipo = (GetTextValue(element, "tp_sinal") == "C" ? "Crédito" : "Débito");
    }

    public string Data { get; set; }
    public string Descricao { get; set; }
    public string Valor { get; set; }
    public string Tipo { get; set; }
}

Can someone please explain the anatomy of MasterDetails page?

$
0
0

I'm not sure I understand how everything works together.
To start we have a MainPage which inherits from MasterDetailsPage.
And that is the first thing that gets loaded from App.cs

But it displays what looks like a ContentPage. Is the MasterDetailsPage just the part that slides out from the side when you push the hamburger button? Or is it the entire page in the window?

Is there a link to a diagram to what each part is and how they relate? Or can someone sketch it/describe it?

Thanks

Highlight listview text

$
0
0

I have a listview and search bar in my apps, I able to filterr the list based on the search bar input but I dont know how to hightlight the listview text that contain the search bar input. Can anyone help?


Listview is not populating after navigation

$
0
0

I have listview defined in xaml as below:
<ListView x:Name="Iv" ItemSelected="Iv_ItemSelected" ItemsSource="{Binding deviceListEx}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="{Binding .}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

This does work in first page load, however in ios platform when I navigate to another page then back to the listview page by clicking back button, the page is blank, means listview is not populated.
Application is in c# and working fine in android.

Have anyone faced such issue or similar issue? Do let me know how can I solve this.

New Xamarin.Forms Guide: Web Services

$
0
0

Xamarin.Forms apps can consume web services implemented using a wide variety of technologies. A new guide on consuming and authenticating access to web services using Xamarin.Forms has recently been published. The guide describes how to communicate with different web services in order to provide create, read, update, and delete (CRUD) functionality to Xamarin.Forms applications, and how to integrate authentication services into Xamarin.Forms applications in order to enable users to share a back-end while only having access to their own data. Topics covered include:

To understand the sample code provided with the guide you should be familiar with the basic principles of web services, Xamarin.Forms applications that use XAML, and asynchronous programming using Tasks. For more information see Introduction to Web Services, Getting Started with Xamarin.Forms, and Async Support Overview.

Where to start?

The suggested reading route for the guide is as follows:

image

Exploring the guide

The guide includes the following topics:

  • Understanding the Sample
    This topic provides a walkthrough of the Xamarin.Forms sample application that’s used to demonstrate how to communicate with different web services. Topics covered include the anatomy of the application, the pages, data model, and invoking web service operations.

  • Consuming an ASP.NET Web Service (ASMX)
    ASP.NET Web Services (ASMX) provide the ability to build web services that send messages over HTTP using Simple Object Access Protocol (SOAP). SOAP is a platform-independent and language-independent protocol for building and accessing web services. Consumers of an ASMX service do not need to know anything about the platform, object model, or programming language used to implement the service. They only need to understand how to send and receive SOAP messages. This topic demonstrates how to consume an ASMX web service from a Xamarin.Forms application.

  • Consuming a Windows Communication Foundation (WCF) Web Service
    WCF is Microsoft's unified framework for building service-oriented applications. It enables developers to build secure, reliable, transacted, and interoperable distributed applications. There are differences between ASP.NET Web Services (ASMX) and WCF, but it is important to understand that WCF supports the same capabilities that ASMX provides — SOAP messages over HTTP. This topic demonstrates how to consume an WCF SOAP service from a Xamarin.Forms application.

  • Consuming a RESTful Web Service
    Representational State Transfer (REST) is an architectural style for building web services. REST requests are made over HTTP using the same HTTP verbs that web browsers use to retrieve web pages and to send data to servers. This topic demonstrates how to consume a RESTful web service from a Xamarin.Forms application.

  • Consuming an Azure Mobile Service
    Azure Mobile Services is a scalable mobile application development platform that enables the functionality of mobile applications to be enhanced by using Azure. This topic, which is only applicable to Azure Mobile Services that use a JavaScript back-end, explains how to use the Xamarin component for Azure Mobile Services to query, insert, update, and delete data stored in a table in an Azure Mobile Services instance.

  • Consuming an Amazon SimpleDB Service
    Amazon SimpleDB is a web service that provides the ability to store and query data in Amazon's cloud. This topic explains how to use the AWS SDK for .NET to query, create and replace, and delete data stored in a SimpleDB service.

  • Consuming a Parse Service
    Parse provides backend solutions for mobile applications, eliminating the need for writing server code and maintaining servers. This topic demonstrates how to consume a Parse web service from a Xamarin.Forms application.

  • Authenticating a RESTful Web Service
    HTTP supports the use of several authentication mechanisms to control access to resources. Basic authentication provides access to resources to only those clients that have the correct credentials. This topic demonstrates how to use basic authentication to protect access to RESTful web service resources.

  • Authenticating Users with an Identity Provider
    Xamarin.Auth is a cross-platform SDK for authenticating users and storing their accounts. It includes OAuth authenticators that provide support for consuming identity providers such as Google, Microsoft, Facebook, and Twitter. This topic explains how to use Xamarin.Auth to manage the authentication process in a Xamarin.Forms application.

  • Authenticating Users with Azure Mobile Services
    Azure Mobile Services uses a variety of external identity providers to support authenticating and authorizing application users. Permissions can then be set on tables to restrict access to only authenticated users. This topic explains how to use Azure Mobile Services to manage the authentication process in a Xamarin.Forms application.

  • Authenticating Users with an Amazon SimpleDB Service
    Amazon SimpleDB does not offer its own resource-based permissions system. Instead, authentication against an identity provider can be used to ensure that users only have access to their own data in the SimpleDB domain. This topic explains how to restrict users' access to their own SimpleDB data.

  • Authenticating Users with a Parse Service
    The Parse .NET SDK provides classes to add user management and access control lists to an application. This topic demonstrates how to add user account functionality to a Xamarin.Forms application, and how to use access control lists to limit data access to the creating user.

Exploring the samples

Along with the guide there are also sample apps that demonstrate the concepts explained in the guide:

  • TodoASMX
    This sample demonstrates a Todo list application where the data is stored and accessed from an ASP.NET Web Service (ASMX).

  • TodoWCF
    This sample demonstrates a Todo list application where the data is stored and accessed from a Windows Communication Foundation (WCF) web service.

  • TodoREST
    This sample demonstrates a Todo list application where the data is stored and accessed from a RESTful web service.

  • TodoAzure
    This sample demonstrates a Todo list application where the data is stored and accessed from an Azure Mobile Service instance.

  • TodoAWS
    This sample demonstrates a Todo list application where the data is stored and accessed from a SimpleDB service in Amazon Web Services.

  • TodoParse
    This sample demonstrates a Todo list application where the data is stored and accessed from a Parse web service.

  • TodoAzureAuth
    This sample demonstrates a Todo list application where the data is stored, accessed, and authenticated from an Azure Mobile Service instance.

  • TodoAWSAuth
    This sample demonstrates a Todo list application where the data is stored and accessed from a SimpleDB service in Amazon Web Services, with authentication occurring with a Google login.

  • TodoParseAuth
    This sample demonstrates a Todo list application where the data is stored, accessed, and authenticated from a Parse web service.

How can I implement live filter on my custom camera renderer?

$
0
0

I'm developing custom camera app currently, and I want to implement live filter on my app. However, it's too difficult to do it.
I did following jobs: overlay transparent image(adjusting with opacity) with imageView on my textureView which renders camera preview. But in fact, this way couldn't work real filter(just adjusting opacity) and also can't save the photo. How can I do? :( Please help me

How can i change color for statusbar on ios(xamarin forms)

$
0
0

I have a dark background, so id like to change the statusbar color on ios to white. I mean only text and keep transparent...

Thanks

Application Architecture with no Database

$
0
0

Hi,
Referring to the documentation related to Application architecture of Tasky sample, I would like to know how an application architecture looks like when there is no local database.

My application's UI is built using Xamarin.Forms. I use Wikitude SDK to build and AR application. The Wikitude SDK is added as a nuget package on both iOS and Android platforms. The applications use the assets data such as images, JS files, etc.. but I have not used any database. Now, how should I draw the Architecture diagram of my application. Should I remove the Data Layer from the architecture? If so, how should I show the Asset files in each platform?

My application looks like this.

Upload byte array to server with progress percentages in Xamarin.Forms

$
0
0

I am trying to upload a byte array from Xamarin.Forms application using HttpClient. So far it's getting uploaded but I am not able to get upload progress. Is there any way to get an upload progress in percentage while file is being uploaded to server?

Here is a code snippet I am using for byte array upload.

var bytearray = videoData;
var uploadRequestBody = new ByteArrayContent(bytearray, 0, bytearray.Length);
uploadRequestBody.Headers.ContentLength = bytearray.Length;
uploadRequestBody.Headers.ContentType = new 
MediaTypeWithQualityHeaderValue("video/mp4");
HttpClient uploadRequestClient = new HttpClient();
uploadRequestClient.Timeout = TimeSpan.FromMinutes(60);
var uploadRequest = new HttpRequestMessage(HttpMethod.Put, <Some URL Endpoint>);
uploadRequest.Content = uploadRequestBody;
var uploadResponse = await uploadRequestClient.SendAsync(uploadRequest);
var uploadResponseResult = uploadResponse.Content.ReadAsStringAsync().Result;

Thanks in advance.

UWP BluetoothRfcoom DataReader "The operation identifier is not invalid”

$
0
0

I'm conneting to a device with bluetooth (UWP application) and during the connectionstate I'm available to read the data I want. However when the connection phase is complete, I'm running calls to the device every 250ms from a System.Timer from my .NET standard project.

When I do this, depening on how i create the DataWriter and DataReader (static or foreach call) I either hang forever or get:

"The operation identifier is not valid".

await dataReader.LoadAsync(Convert.ToUInt32(size));
dataReader.ReadBytes(buffer);

I have tested to run the application in a singlethreaded UWP application where it works fine. Is there any way around this? Feels like its Xamarin.

Otherwise would I need to re-write the entire functionallity for this. We are doing a cross-plattform (Xamarin) where the customer also want an UWP application to run on their Windows Tablet.


Globalization, Localization Xamarin.Forms

$
0
0

Hello World,

I'm using Visual Studio for Mac, to build iOS and Droid Applications
I'm searching an easy way to make internalisation on my Application.

First I try this way https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/localization/
But all *.Designer.cs are not auto generated.
Seems I got some problem with ResXFileCodeGenerator. ("Can only be use with .NET project" => Best Error ever in C#!)

Second I tried this way https://github.com/xleon/I18N-Portable,
but the I18n don't find my Locales folder with all en.txt *.txt
Seems I got problems with ressource files

If you got any idea why I can't make it works
Please help me

If you got any third library that can make my life easier with internationnalisation, like I18n can do when it's working.
Please tell me

Thanks by advance for your answers

how to deserialize nested json.

$
0
0

I am getting nested json in response of an API.

App is crashing while deserializing the json.

MasterDetailPage need new features (Width, Right to Left, Animations)

$
0
0

MasterDetailPage need missing features
(Width property , Right to Left direction property, animation property)

Sorry, but I have to open that has an issue since developers have to move around,
to get a nice side menu on smartphones. Don't you think?

Up the issue please ;)
github.com/xamarin/Xamarin.Forms/issues/1841

Actual Behavior
We are stuck from the left to right, with a fixed width.
But the slide gestures is awesome!

Expected Behavior
A great implementation, with some customisable properties available
_Right to left
_Width property
_Animation property (we need same animations for both device IOS, Android)

Steps to Reproduce
Implement a MasterDetailPage
Figure it out that you can't change the width of the MasterDetailPage
Realize that you can't get the MasterDetailPage from right to left
Dawn on that you never gonna get two side menu.

Xamarin forms UWP hybrid webview not calling jquery ajax.

$
0
0

I have implemented the Hybrid webview in xamarin forms. As mentioned I have included the index.html file with jquery library from web which is working in android, when I check the same in UWP it is not working, after i have copied the jquery content to local file and then success ed. When I try to implement the ajax jquery to get token. Nothing happens, how to fix and how to debug the script in html page.

How to Drag and Drop BoxView in Xamarin Forms Standard?

$
0
0

I want Drag and Drop BoxView.

so i maked pangesture and write the code

private void BoxViewPanUpdated(object sender, PanUpdatedEventArgs e) { if(e.StatusType == GestureStatus.Running) { boxview.TranslateX = e.TotalX; boxview.TranslateY = e.TotalY; } else if(e.StatusType == GestureStatus.Completed) { System.Diagnostics.Debug.WriteLine("Pan Ended"); } .... }

upper source code is example source.

Play that program, i expected to see the string "Pan Ended" when i up my finger from phone's screen,

but PanGesture's Completed or Canceld Status are not Constant.

I want move boxview to appointed position when my finger up from screen.

For example when the boxview's position is over (100,100) and my finger is not touch screen any more, the boxview's position translate to (200,200).

How can i detect screen's touch event exately?

Viewing all 58056 articles
Browse latest View live


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