Ejemplo n.º 1
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            _window = new UIWindow();
            var app = new MyApp();

            IView content = app.CreateView();

            _window.RootViewController = new UIViewController
            {
                View = content.ToNative()
            };

            _window.MakeKeyAndVisible();

            // In 5 seconds, add and remove some controls so we can see that working
            Task.Run(async() => {
                await Task.Delay(5000).ConfigureAwait(false);

                void addLabel()
                {
                    (content as VerticalStackLayout).Add(new Label {
                        Text = "I show up after 5 seconds"
                    });
                    var first = (content as VerticalStackLayout).Children.First();
                    (content as VerticalStackLayout).Remove(first);
                };

                _window.BeginInvokeOnMainThread(addLabel);
            });

            return(true);
        }
Ejemplo n.º 2
0
        public ViewController(IntPtr handle) : base(handle)
        {
            var app = new MyApp();

            IView content = app.CreateView();

            View = content.ToNative();
        }
Ejemplo n.º 3
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            _window = new UIWindow();
            var app = new MyApp();

            IView content = app.CreateView();

            _window.RootViewController = new UIViewController
            {
                View = content.ToNative()
            };

            _window.MakeKeyAndVisible();

            return(true);
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            AndroidX.AppCompat.Widget.Toolbar toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            _page = FindViewById <ViewGroup>(Resource.Id.pageLayout);

            var app = new MyApp();

            Add(app.CreateView());
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            AndroidX.AppCompat.Widget.Toolbar toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            _page = FindViewById <ViewGroup>(Resource.Id.Page);

            var app = new MyApp();

            var view = app.CreateView();

            Add(view);


            // In 5 seconds, add and remove some controls so we can see that working
            Task.Run(async() => {
                await Task.Delay(5000).ConfigureAwait(false);

                void addLabel()
                {
                    (view as VerticalStackLayout).Add(new Label {
                        Text = "I show up after 5 seconds"
                    });
                    var first = (view as VerticalStackLayout).Children.First();
                    (view as VerticalStackLayout).Remove(first);
                };

                new Handler(Looper.MainLooper).Post(addLabel);
            });
        }