Esempio n. 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            var serializer = new JsonSerializer();

            if (bundle != null)
            {
                this.model = serializer.Deserialize <SimpleViewModel>(bundle.GetString("model"));
            }

            var button = this.FindViewById <Button>(Resource.Id.buttonClose);

            button.Click += (sender, args) =>
            {
                var intent = new Intent();
                intent.PutExtra("model", serializer.Serialize(this.model));
                this.SetResult(Result.Ok, intent);
                this.Finish();
            };
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            var button    = FindViewById <Button>(Resource.Id.buttonOpen);
            var viewModel = new SimpleViewModel()
            {
                Label = "Text",
                Text  = string.Empty
            };

            button.Click += delegate
            {
                var serializer = new JsonSerializer();
                var intent     = new Intent(this, typeof(Activity2));
                intent.PutExtra("model", serializer.Serialize(viewModel));
                this.StartActivityForResult(intent, Resource.Id.buttonOpen);
            };
        }