public NavigationExample()
        {
            var btnNavigate = new Button {Text = "Navigate to another Page"};
            var btnPopup = new Button {Text = "Show Popup"};

            _popup = new Popup
            {
                XPositionRequest = 0.5,
                YPositionRequest = 0.2,
                ContentHeightRequest = 0.1,
                ContentWidthRequest = 0.4,
                Padding = 10,

                Body = new ContentView
                {
                    BackgroundColor = Color.White,
                    Content = new Label
                    {
                        VerticalTextAlignment = TextAlignment.Center,
                        HorizontalTextAlignment = TextAlignment.Center,
                        TextColor = Color.Black,
                        Text = "Hello, World!"
                    }
                }
            };

            // Initialize event handlers
            btnPopup.Clicked += BtnPopup_Clicked;
            btnNavigate.Clicked += BtnNavigate_Clicked;
            _popup.Tapped += Popup_Tapped;

            // Notice _popup is not added to this ContentPage
            Content = new StackLayout
            {
                Padding = 15,

                Children =
                {
                    btnNavigate,
                    btnPopup
                }
            };

            // Initialize popup view
            var _ = new PopupPageInitializer(this) { _popup };

            // Child page that will opened via btnPopup.Clicked
            _childPage = new ContentPage
            {
                Content = new Label
                {
                    Text = "Hello, World!"
                }
            };
        }
Example #2
0
        public CodedPopupExample()
        {
            _closeOnAnyTap = new SwitchCell {
                Text = "Close on any tap", On = true
            };
            _preventShowing = new SwitchCell {
                Text = "Prevent popup from showing"
            };
            _displayTappedSection = new SwitchCell {
                Text = "Display the tapped section's name"
            };
            _showingAnimation = new SwitchCell {
                Text = "Turn on 'Showing' animation"
            };

            var showPopup = new Button {
                Text = "Show Popup"
            };

            var closeButton = new Button
            {
                Text            = "Close",
                TextColor       = Color.FromHex("#D37E00"),
                BackgroundColor = Color.White,
            };

            _popup1 = new Popup
            {
                XPositionRequest     = 0.5,
                YPositionRequest     = 0.5,
                ContentWidthRequest  = 0.8,
                ContentHeightRequest = 0.5,

                Header = new ContentView
                {
                    Padding         = 10,
                    BackgroundColor = Color.FromHex("#3399FF"),
                    Content         = new Label
                    {
                        FontSize  = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                        TextColor = Color.White,
                        Text      = "Simple popup"
                    }
                },

                Body = new ContentView
                {
                    Padding         = 10,
                    BackgroundColor = Color.White,
                    Content         = new Label
                    {
                        FontSize  = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                        TextColor = Color.Gray,
                        Text      = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
                    }
                },

                Footer = new ContentView
                {
                    BackgroundColor = Color.White,

                    Content = new StackLayout
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.EndAndExpand,
                        Children          = { closeButton }
                    }
                }
            };

            // Required to be instantiated before the popup is added to ContentPage.Content
            var popupInit = new PopupPageInitializer(this)
            {
                _popup1
            };

            Content = new StackLayout
            {
                Children =
                {
                    new TableView
                    {
                        Intent = TableIntent.Settings,
                        Root   = new TableRoot
                        {
                            new TableSection("Coded Popup Example")
                            {
                                _closeOnAnyTap,
                                _preventShowing,
                                _displayTappedSection,
                                _showingAnimation
                            }
                        },
                    },

                    showPopup
                }
            };


            _popup1.Tapped      += Popup1_Tapped;
            _popup1.Showing     += Popup1_Showing;
            showPopup.Clicked   += ShowPopup_Clicked;
            closeButton.Clicked += CloseButton_Clicked;
        }
        public NavigationExample()
        {
            var btnNavigate = new Button {
                Text = "Navigate to another Page"
            };
            var btnPopup = new Button {
                Text = "Show Popup"
            };

            _popup = new Popup
            {
                XPositionRequest     = 0.5,
                YPositionRequest     = 0.2,
                ContentHeightRequest = 0.1,
                ContentWidthRequest  = 0.4,
                Padding = 10,

                Body = new ContentView
                {
                    BackgroundColor = Color.White,
                    Content         = new Label
                    {
                        VerticalTextAlignment   = TextAlignment.Center,
                        HorizontalTextAlignment = TextAlignment.Center,
                        TextColor = Color.Black,
                        Text      = "Hello, World!"
                    }
                }
            };


            // Initialize event handlers
            btnPopup.Clicked    += BtnPopup_Clicked;
            btnNavigate.Clicked += BtnNavigate_Clicked;
            _popup.Tapped       += Popup_Tapped;


            // Notice _popup is not added to this ContentPage
            Content = new StackLayout
            {
                Padding = 15,

                Children =
                {
                    btnNavigate,
                    btnPopup
                }
            };

            // Initialize popup view
            var _ = new PopupPageInitializer(this)
            {
                _popup
            };

            // Child page that will opened via btnPopup.Clicked
            _childPage = new ContentPage
            {
                Content = new Label
                {
                    Text = "Hello, World!"
                }
            };
        }
Example #4
0
 protected PopupPage()
 {
     _popupInit = new PopupPageInitializer(this);
     Popups = new ObservableCollection<Popup>();
     Popups.CollectionChanged += Popups_CollectionChanged;
 }