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

NullReference on StackLayout.Children.Add

$
0
0

I am getting a NullReference exception from Xamarin.Forms when calling :

var contentView = new ContentView();
contentView.Content = new StackLayout();
var stackLayout = new StackLayout();
stackLayout.Children.Add(contentView);

StackTrace :

{System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Forms.NavigationProxy.set_Inner (INavigation value) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.VisualElement.OnParentSet () [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Element.set_Parent (Xamarin.Forms.Element value) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Element.OnChildAdded (Xamarin.Forms.Element child) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Layout.OnInternalAdded (Xamarin.Forms.View view) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
  at (wrapper delegate-invoke) <Module>:invoke_void__this___object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
  at (wrapper delegate-invoke) <Module>:invoke_void__this___object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
  at System.Collections.ObjectModel.ObservableCollection`1[Xamarin.Forms.Element].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 
  at System.Collections.ObjectModel.ObservableCollection`1[Xamarin.Forms.Element].InsertItem (Int32 index, Xamarin.Forms.Element item) [0x00000] in <filename unknown>:0 
  at System.Collections.ObjectModel.Collection`1[Xamarin.Forms.Element].Add (Xamarin.Forms.Element item) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.ObservableWrapper`2[Xamarin.Forms.Element,Xamarin.Forms.View].Add (Xamarin.Forms.View item) [0x00000] in <filename unknown>:0 
  at Core.ListPage`3+<>c__DisplayClass4[Core.PunchHistoryItem,Core.PunchHistoryCommand,Core.PunchHistoryDetail].<.ctor>b__1 (System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) [0x0005e] in c:\WIP\Xamarin\XamarinPOC.Forms\Core\Pages\ListPage.cs:85 }

Viewing all articles
Browse latest Browse all 58056

Trending Articles



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