Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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="Assignment6.MyPage">
- <ContentPage.Content>
- <StackLayout>
- <ListView x:Name = "ListviewItems" />
- <ListView.ItemTemplate>
- <DataTemplate>
- <ViewCell>
- <ViewCell.View>
- <StackLayout>
- <Label Text = "{Binding date}" />
- <Label Text = "{Binding meetingLocation}" />
- </StackLayout>
- </ViewCell.View>
- </ViewCell>
- </DataTemplate>
- </ListView.ItemTemplate>
- </StackLayout>
- </ContentPage.Content>
- </ContentPage>
- namespace Assignment6
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class MyPage : ContentPage
- {
- private ObservableCollection<Reservation> items = new ObservableCollection<Reservation>();
- public MyPage()
- {
- InitializeComponent();
- Init();
- }
- public void Init()
- {
- BindingContext = new Reservation();
- var enumerator = App.UserDatabase.GetReservation();
- while (enumerator.MoveNext())
- {
- items.Add(enumerator.Current);
- }
- ListviewItems.ItemsSource = items;
- }
- }
- }
- public class Reservation
- {
- [PrimaryKey][AutoIncrement]
- public int date { get; set; }
- public int startingTime { get; set; }
- public string duration { get; set; }
- public int meetingLocation { get; set; }
- public Reservation()
- {
- }
- public Reservation(int date, int startingTime, string duration, int meetingLocation)
- {
- this.date = date;
- this.startingTime = startingTime;
- this.duration = duration;
- this.meetingLocation = meetingLocation;
- }
- }
- void Handle_Clicked(object sender, System.EventArgs e)
- {
- DisplayAlert("Reservation", "Your reservation for a " + Output.Text + " meeting in room " + Room.SelectedIndex +
- " starting at " + Time.Time + " on " + Date.Date.Month + "/" + Date.Date.Day + "/" + " " + Date.Date.Year + " for " + Slide.Value.ToString() + " hours has been added.", "OK");
- Reservation reserve = new Reservation(Date.Date.Month, Time.Time.Hours, Slide.Value.ToString(), Room.SelectedIndex);
- App.UserDatabase.SaveReservation(reserve);
- }
- System.InvalidCastException: Specified cast is not valid.
- at Xamarin.Forms.ItemsView`1+<>c[TVisual].<.cctor>b__24_0 (Xamarin.Forms.BindableObject b, System.Object v) [0x00000] in D:a1sXamarin.Forms.CoreItemsView.cs:25
- at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00071] in D:a1sXamarin.Forms.CoreBindableObject.cs:387
- at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0003d] in D:a1sXamarin.Forms.CoreBindableObject.cs:573
- at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:a1sXamarin.Forms.CoreBindableObject.cs:99
- at Assignment6.MyPage.InitializeComponent () [0x00023] in /Users/zane/Projects/Assignment6/Assignment6/obj/Debug/netstandard2.0/MyPage.xaml.g.cs:26
- at Assignment6.MyPage..ctor () [0x00013] in /Users/zane/Projects/Assignment6/Assignment6/MyPage.xaml.cs:16
- at Assignment6.MainPage+<Handle_Clicked_1>d__2.MoveNext () [0x0000f] in /Users/zane/Projects/Assignment6/Assignment6/MainPage.xaml.cs:33
- at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.13/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1023
- at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.13/src/Xamarin.iOS/Foundation/NSAction.cs:178
- at 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 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.13/src/Xamarin.iOS/UIKit/UIApplication.cs:79
- at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.13/src/Xamarin.iOS/UIKit/UIApplication.cs:63
- at Assignment6.iOS.Application.Main (System.String[] args) [0x00001] in /Users/zane/Projects/Assignment6/Assignment6.iOS/Main.cs:17
Add Comment
Please, Sign In to add comment