Пример #1
0
        public NfcDevicePage()
        {
            this.Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);

            this.device = DependencyService.Get<INfcDevice>();

            var stack = new StackLayout();

            if (this.device == null)
            {
                stack.Children.Add(new Label()
                {
                    TextColor = Color.Red,
                    Text = "No NFC support",

                });
            }
            else
            {
                stack.Children.Add(new Label()
                {
                    Text = "Connection state",
                });

                var s = new Switch()
                {
                    IsEnabled = false,
                    HorizontalOptions = LayoutOptions.FillAndExpand
                };

                s.SetBinding(Switch.IsToggledProperty, "Connected");
                s.BindingContext = this;

                stack.Children.Add(s);
            }

            this.Content = stack;
        }
Пример #2
0
        public NfcDevicePage()
        {
            this.Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);

            this.device = DependencyService.Get <INfcDevice>();

            var stack = new StackLayout();

            if (this.device == null || !this.device.IsEnabled)
            {
                stack.Children.Add(new Label()
                {
                    TextColor = Color.Red,
                    Text      = "No NFC support",
                });
            }
            else
            {
                stack.Children.Add(new Label()
                {
                    Text = "Connection state",
                });

                var s = new Switch()
                {
                    IsEnabled         = false,
                    HorizontalOptions = LayoutOptions.FillAndExpand
                };

                s.SetBinding(Switch.IsToggledProperty, "Connected");
                s.BindingContext = this;

                stack.Children.Add(s);
            }

            this.Content = stack;
        }